Loonng Story short, I came up with the idea of making a int that gets a char from 'getchar();' and shows the char AND the int value! I betcha I'm not the first one to make this program but's it's really really neat to me!
#include <stdio.h>
#define nl printf("\n")//time saving marco
int main(){ //'getintchar' program
int mychr;
printf("ASCII Number Printer 1.0\t\tby CKarl\n\
Type anything and press enter to see the ASCII number next to the char!\n\
Press tab then enter to exit\n");
>BTW<
Linefeed(enter) is 10 and you can't see the character and it always slaps it on sence you pressed enter, for excixse someone could make it so it doesn't print a line feed
handy, definitely, but it could do with being in windows form (with two little edit boxes side-by-side)
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
one problem with that...I know NOTHING about ANY TYPE of GUI with either C OR C++ UNLESS you know of a good tut...you won't be seeing any window apps for this
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
printf("ASCII Number Printer 1.0\t\tby CKarl\n\
Type anything and press enter to see the ASCII number next to the char!\n\
Press tab then enter to exit\n");
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
// the now useless functions that I keep here to just becuz',
// cls() needs working..
void cls(void); //handy cls function
void locate(int x,int y); //nice locate func
#define nl printf("\n")
#define intro printf("ASCII Number Printer 1.05\t\tby CKarl with help from Kris and Chris\n\
Type anything and press enter to see the ASCII number next to the char!\n\
Press tab then enter to exit\n")
int main(){ //'getintchar' program
int mychr,flg=0;
// Make Window
myWindow = New Window(320,240,0xFFFFFF,15,"Get Char Value");
// Center window so it's easier to see
myWindow.CENTER();
// For Inputting Value
myEdit = New Edit(myWindow,"Enter String Here",4,4,312,104,Edit.VSCROLL,Edit.MULTILINE);
// For Result
myEditResult = New Edit(myWindow,"Click Button for Result",4,112,312,104,Edit.VSCROLL,Edit.MULTILINE);
// Button for calling function
myButton = New Button(myWindow,"Get Values",252,216,64,20);
// Mouse Clicked
myButton.OnClick = Click;
Function Click(btn)
{
// "myButton" clicked, so get Result
If(btn == myButton)
{
// Calls function and passes string
myEditResult.SetText(GetChars(myEdit.GetText()));
}
}
// Get Char Values of String
Function GetChars(pString)
{
// String to Get Values from
This.myString = pString;
// Result to store Values
This.myResult = "";
// Get all Char Values
For(n = 0;n < This.myString.Length();n++)
{
// Get Char Value
This.myChar = This.myString.SubString(n,1);
// Store Char Value
This.myResult += This.myChar.GetAscii()+".";
}
// Return result to editbox
Return This.myResult.SubString(0,This.myResult.Length()-1);
}
// Keep Program Running
While(1);
Edit: Does anyone else find the CODE tag makes it hard to read? All those line breaks, I mean.
Karl, did you know about inline functions? They work more-or-less the same as pre-processor #defines but are a lot neater:
inline void intro() {
printf("ASCII Number Printer 1.05\t\tby CKarl with help from Kris and Chris\n\
Type anything and press enter to see the ASCII number next to the char!\n\
Press tab then enter to exit\n")
}
Now whenever you do intro();, the code from the intro() function will just be inserted in its place, instead of the function actually being called, so there's no speed loss.
Edited by the Author.
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G