Hi rohitdivas,
Assuming that string "rohit" or "rohit\n" is in variable str of type char *.
int i = strlen (str);
if ( str[i-1] == '\n' )
printf ("newline found");
Incase it is possible that \n can occur in the middle of str, then you will have to traverse char by char
int i =0;
while ( str[i] != '\n' && str[i] != '\0' )
i++;
if (str[i] == '\n')
printf ("newline found");
Cheers!
sunnycoder
Main Topics
Browse All Topics





by: leewPosted on 2005-01-05 at 23:43:25ID: 12969950
I really can't help with anything but to say:
ASCII Value of Enter Key is a Carriage Return, typically. That is value 13 (Decimal).
Windows often uses Carriage Return - Line Feed, which is ASCII 13 decimal, ASCII 10 Decimal.