Im still learning C and I have a few questions about making a array of strings.
Im doing an assignment for school, and I'm a little stuck with my program.
Here is my code so far:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
FILE* fin;
int a;
char myString[3];;
fin=fopen(argv[1],"r");
fscanf((fin,"%s", &myString)!=EOF);
putchar('\n');
printf("%s\n", myString);
return 0;
}
What I am trying to accomplish is to create a program that will take individual characters from a file, each on a separate line, and compose them into a single string in memory while keeping the first character within the file as the memory counter and not part of the string array of correct length and size.
Input file looks like this:
3
a
b
c
I am able to read in the characters all at once but cant seem to understand how to read them in individually, and to create a array of the character string. Any help would be great, thank you !