Lesson 9 in the C tutorial says the declaration of fgets calls for a FILE* but will take stdin. But when I try this with my own function (which I'm trying to generalize) I get a warning:
Code:
warning: passing argument 1 of ‘readLine’ from incompatible pointer type
Why? Here's the code:
Code:
#include <stdio.h>
#include <string.h>
void readLine(char* string, FILE* stream){
int i;
fgets(string, strlen(string), stream);
for(i = 0; i < strlen(string); i++){
if(string[i] == '\n'){
string[i] = '\0';
return;
}
}
return;
}
int main(){
char* input[256];
printf("Please enter a number: ");
readLine(input, stdin);
printf("You entered %s.\n", input);
return 0;
}