I want to cut off everything in a text file after the strings being separated by a space on each line, so if for example the text file contains the Line:
I am a String.
Iam a String too.
There would only be I
in the output file on the first line of the output file, and on the second line there only would be Iam
left of the line.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
FILE *input,*output;
char line[40];
if(argc == 3){
input = fopen(argv[1],"r");
output = fopen(argv[2],"w");
if(input!= NULL){
while(!feof(input)){
fgets(line,sizeof line,input);
strtok(line," ");
fputs(line,output);
}
fclose(input);
fclose(output);
}
}
}
this is how it'S almost completeley is working although its obfuscating more lines with each others :/