ASCII to Decimal, Hexadecimal, and Octal
This program will convert ASCII to decimal, hexadecimal, and octal.
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main()
{
char string[1024];
int length;
printf("ASCII Input: ");
gets(string);
printf("\n");
printf("\n");
printf("Decimal Ouput: ");
for(length = 0; length < strlen(string); length++)
{
printf("%d ", string[length]);
}
printf("\n");
printf("Hexadecimal Output: ");
for(length = 0; length < strlen(string); length++)
{
printf("%x ", string[length]);
}
printf("\n");
printf("Octal Output: ");
for(length = 0; length < strlen(string); length++)
{
printf("%o ", string[length]);
}
printf("\n");
printf("\n");
system("pause");
return 0;
}
'Example Of Use
'sRet = RunDosCommand("CScript.exe C:\MyScript.vbs", 10)
Function RunDosCommand(ByVal sCommandText As String, Optional ByVal iTimeOutSec As Integer = 1) As String
Dim iPos As Integer = sCommandText.IndexOf(" ")
Dim sFileName As String
Dim sArguments As String = ""
If iPos = -1 Then
sFileName = sCommandText
Else
sFileName = sCommandText.Substring(0, iPos)
sArguments = sCommandText.Substring(iPos + 1)
End If
Dim sRet As String
Dim oProcess As Process = New Process
oProcess.StartInfo.UseShellExecute = False
oProcess.StartInfo.RedirectStandardOutput = True
oProcess.StartInfo.FileName = sFileName
oProcess.StartInfo.Arguments = sArguments
oProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
oProcess.StartInfo.CreateNoWindow = True
oProcess.Start()
oProcess.WaitForExit(1000 * iTimeOutSec)
If Not oProcess.HasExited Then
oProcess.Kill()
Return "Timeout"
End If
sRet = oProcess.StandardOutput.ReadToEnd()
If oProcess.ExitCode <> 0 And sRet = "" Then
sRet = "ExitCode: " & oProcess.ExitCode
End If
oProcess.Close()
Return sRet
End Function
Original Comments (3)
Recovered from Wayback Machine