I wrote this function which is supposed to read a string into an array up to the NULL char which represents the end of the string in the line. But it somehow doesn't quite work.
int main(void){
int MAX = 39;
char number1[MAX + 1];
int i;
read_array(number1, MAX);
for(i = 0; i <= MAX; i++)
printf("%c", number1[i]);
return 0;
}
int read_array(char* number, int size) {
printf("\nEnter an integer number at a maximum of 39 digits please.\n");
int result = 0;
char* i;
for (i = number; *i != NULL; i++)
scanf("%c", i);
return result;
}
No matter how many chars I type, as I print the result it just gives me the first 3 chars and I don't understand why. Any idea? THX