FILE
THE FIRST LINE IS THE HEADING THAT I WANT TO DISCONTINUE. So that the counter "num" does not begin counting from the HEADER
Company About Name Function
CompanyA Bedecs Anna Owner
CompanyB Gratacos Antonio Owner
CompanyC Axen Thomas Shopping
CompanyD Lee Christina Manager
CompanyE ODonnell Martin Owner
CompanyF PrezOlaeta Francisco Manager
CompanyG Xie Ming-Yang Owner
Company Andersen Elizabeth Representative
CompanyI Mortensen Sven Shopping
Company J Wacker Roland Shopping
CompanyK Krschne Peter Manager
CompanyL Edwards John Manager
CompanyM Ludick Andre Representative
CompanyN Grilo Carlos Representative
CompanyO Kupkova Helena Manager
CompanyP Goldschmidt Daniel Representative
CompanyQ Bagel Jean Proprietary
CompanyR Autier Catherine Representative
Company Eggerer Alexander Accounting
CompanyT Li George Manager
Company U Tham Bernard Manager
Company Ramos Luciana Assistant
CompanyW Entin Michael Manager
CompanyX Hasselberg Jonas Owner
Company And Rodman John Manager
CompanyZ Liu Run Wizard
CompanyAA Toh Karen Manager
CompanyBB Raghav Amritansh Manager
Company CC Lee Soo Manager
SOURCE CODE BELOW
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <unistd.h>
main(){
FILE * input_text, *output_text;
char line[1024];
char * last;
int num = 0;
setlocale(LC_CTYPE,"");
if((input_text = fopen("entrada03.txt","r")) == NULL)
printf("\n[ERRO]Travou o Nintendo!\n");
else
printf("\n[SUCESSO]Sucesso ao abrir o arquivo!\n\n");
printf("\n\nImprimindo a saida\n\n");
sleep(2);
output_text = fopen("saida02.txt","w");
while(!feof(input_text)){
fgets(line, 1024, input_text);
last = strtok(line, "\n"); //"last" recebe variável "line" até o delimitador "\n"
while(last != NULL){ //Se last não for "NULL" executa essa
printf("%d: %s\n",num, last);
last = strtok(NULL, "\n"); //Se last for "NULL" até o delimitador "\n"
fprintf(output_text,"%d: %s\n", num, line);
}
num++;
}
fclose(input_text);
fclose(output_text);
printf("\n");
system("pause");
}