I am planing to make a C program using array of structures which takes input as strings i.e., name of movie and genre(4 different genres):
struct movie
{
char name[30];
char genre[4][10];
}m[30];
void main()
{
int i,j;
for(i=0;i<30;++i)
{
scanf("%s",m[i].name); //Removing gets
for(j=0;j<4;++j)
{
scanf("%s",m[i].genre[j]); //Removing gets
}
}
}
I want to automate the user input of the program from a pre-defined source e.g a text file, so that I don't have to insert all the input manually. Is there a script(python/bash) to do this or any other method that can make my job easier for 100s of input.
The reason behind using the C program is to store the inputs in a file for future use.
gets. It is insecure.getsfunction fails to notice the overflow, and clobbers adjacent parts of memory.getshas no way to prevent buffer overrun. For that reason, it has been removed from C11.