Quote
char getStringFromFile(FILE *fpin)
{
char *array[256]
fgets(array, 256, fpin);
return array;
}
Should be "char* getStringFromFile(FILE *fpin)"
I'd advise against char *array[256]. use char *array = (char*)malloc(256); instead
Code
int l=0; //this will have your string length
while(ln[l] && l<256) l++;
//do shit with ln
free(ln);
that's your basic way to grab the null terminator, without bursting out of the predefined length
getStringFromFile is a little weak though. fgets won't read the full buffer size if it hits a null character. You're better off feeding the pointer to it as an argument and using it to return the amount of characters read, which will implicitly give you the string length. Also you should consider zeroing the buffer before reading to it, better practice when it comes to random size strings.
This post was edited by flyinggoat on Oct 18 2013 02:41pm