Hi all,
I'm working in the C language.
I've been stuck for 2 weeks trying to figure out how in the world to populate arrays after reading in an input FILE. the input file has numbers and words, I need to write a loop that grabs the integers and stores them in an int array, and also store the characters into the char array. Please Help I'm so desparate. My teacher is no help because he just gets angry at you for not knowing. kinda dumb since im just learning how to do it all. (GEEZ.)
here's what i got....
#include<stdio.h>
#include<stdlib.h>
void read();
int main()
{
read();
return 0;
}
void read()
{
char w[1000];
int n[1000];
int i;
FILE *f;
f = fopen("input.txt","r");
while(i < 1000)
{
if (fscanf(f, "%c%d", &w[i], &n[i])!= EOF)
{
printf("%c%d", w[i], n[i]);
}
else
{
break;
}
}
fclose(f);
}
this doesn't work, but I'm stuck.
Thanks for the help