- Joined
- Nov 30, 2007
- Messages
- 1,202
PHP:
int getStringReg(char s[]) {
int i;
gets(s);
if (s[0] == '\0')
return 0;
for (i = 0; s[i] != '\n'; i++) {
if (s[i] == ' ')
return -1;
}
return 1;
}
Trying to write a small function that returns a string, but only accepting one single word. So i tried to return -1 to the calling function when the input is invalid (space was found). But -1 is never returned.
Last edited: