Well, with 'getch', you're looking for input from the keyboard. That means that this may not work correctly (or at least, not the way you are expecting it to work).
> what i mean by shifting is if the letter was 'a' then it
> becomes 'd', 'x' is sent to 'a', 'z' is sent to c, '3' is sent to '6',
> and '8' is sent to '1'.
> when i used this line nothing happens when i hit enter :
This is what I meant by it won't work correctly. What I would do
is to read an entire line of text first, then pull it from the buffer.
Something like this:
fgets( buf, SIZE_OF_BUFFER, stdin );
Then, read it a character at a time:
for( x = 0; x < SIZE_OF_BUFFER && buf[x] != '\n'; x++ )
... process character ...
> does that meant i need to use:
No. Try this example and you'll see what I mean:
> the next line works, but isnt 13 a type a character in the ascii
int main( void )
printf("To use a single \\, do this: \'%c%c\'\n", '\\', '\\');
printf("To use a newline \\n, use this: \'%c%c\'\n", '\\','n');
printf("To use a single quote, use this: \'%c%c\'\n", '\\','\'');
printf("There are more. Consult your friendly C book.\n" );
> table and not newline?
printf("The newline character's decimal value is: %d\n.", '\n' );
> but in my other programs the first line worked just fine....?
> in the isValid() function how can i validate that the message is
> only consist with digits, lower case letters, and spaces?
This code will stop when the characater in the string is not a alpha-numeric character, and when it isn't a space.
for( x = 0; x < strlen(s) && valid; x++ )
if ( !isalnum( s[x] && !isspace( s[x] ) valid = 0;