Thanks for the replies guys: this is my code and these are my errors. maybe you can spot something i can't
PHP Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define STRING "THIS IS JUST A TEST"
char StringPtr(const char *str);
int main(void){
char StringPtr(const char *str){
/* goes through a string and returns a pointer to the first space else NULL */
while(*str != ' ' && *str != '\0'){
str++;
if (*str == '\0')
return NULL;
else
return str;
}
}
return 0;
}
errors
C:/Dev-Cpp/Ccode/ch11-strings/447no10.c: In function `StringPtr':
C:/Dev-Cpp/Ccode/ch11-strings/447no10.c:15: warning: return makes integer from pointer without a cast
C:/Dev-Cpp/Ccode/ch11-strings/447no10.c:17: warning: return makes integer from pointer without a cast
funny thing is. the example in my book has this same code. and not that it's infalliable (since i've spotted a couple of errors) but you'd think still it'd be correct.
when i attempt to fix it
PHP Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define STRING "THIS IS JUST A TEST"
char *StringPtr(const char *str);
int main(void){
char *StringPtr(const char *str){//now a ptr to char on return
/* goes through a string and returns a pointer to the first space else NULL */
while(*str != ' ' && *str != '\0'){
str++;
if (*str == '\0')
return NULL;
else
return *str;
}
}
return 0;
}
I still get the same error mesage except only one this time. and it points to the line. is this something with DevC++ or what?