The array I'm working with is:
char arr[91][12];
So I populate my array from a file using a for loop like so:
for(i = 0; fgets(arr[i], 12, inFile); i++){}
When I want print anything from that array, it's automatically escaping to the next line.
to test that array:
for(i = 0; fgets(arr[i], 12, inFile); i++){
printf("%s", arr[i]);
}
//one
//two
//three etc.
//want it to be 'one two three etc.'
I'm trying to use strpbrk()
to find \n
for each string in the array and change it to \0
like this:
for(i = 0; fgets(arr[i], 12, inFile); i++){
if(strpbrk(arr[i], "\n") != NULL ){
arr[i][strpbrk(arr[i], "\n")] = '\0';
}
printf("%s", arr[i]);
}
but this gives me errors. Is there a better way to do what I'm trying to do?