View Single Post
Old 10-28-2006, 10:34 AM   #7 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
You need to test for the current location in your string, not c.
Code:
if ((j = isspace(name[i])) == -1)
And delete the int isspace(int c); definition inside your main() function, it has no use, since including ctype.h will already do that.
Perhaps you even want to turn the whole situation around with something like:
Code:
for( i = 0; i < strlen( name ) - 1; ++i )
   if (isalpha(name[i]) || isdigit(name[i]))
      name[i] = name[i] + 1;
So it's only alphanumeric charactors that are beeing transformed.

Or perhaps even, stop relying on a system provided function and hardcode it yourself, like:
Code:
for( i = 0; i < strlen( name ) - 1; ++i )
   if ((name[i] >= 'a' && name[i] <= 'z') || (name[i] >= 'A' && name[i] <= 'Z'))
      name[i] = name[i] + 1;
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote