I am trying to write a C code under UNIX to read the third word from each line of a text, and store it to a string by using POPEN. However my code is giving me an error (Modifiable lvalue required for assignment operator) at the line inside my while loop. Here is my code:
int main() {
int license = 0;
char number[100];
FILE *file = popen("grep User results_today.TXT_05012013 > filename", "r");
if ( file != NULL)
{
char line [128];
while (fgets(line, sizeof line, file) != NULL)
{
number = popen("cut -f3 -d' '", "r");
}
fclose (file);
printf("Hello %s\n", number);
}
I know there are a few errors on here as i am still kinda new to C. But please help me correct them, thanks!