I have an document with some telephone number and andresses. I now try to copy the numbers in one part of a struct and the adress into another. At the moment I was just able to get the data of the document but I can't put it in my struct please help me
C Code
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
struct telefon{
char nummer[16];
char adresse[128];
};
typedef struct telefon TELEFON;
void main()
{
TELEFON tel;
char buffer[256];
FILE *fp;
int i = 0;
int countSemi = 0;
fp = fopen("Telefondatei.txt", "r");
if(fp == NULL)
{
printf("Datei konnte nicht geoeffnet werden.\n");
}
else{
while(fgets(buffer,1000,fp) != 0){
//printf("%s\n",buffer);
while(buffer != 0){
i++;
if(buffer[i] == ';'){
countSemi++;
}
while(countSemi <= 7){
strcpy(tel.adresse,buffer);
printf("%s\n %d \n",tel.adresse,countSemi);
}
}
}
}
}
Example for the data in my .txt document
"Firma";"";"Auto GmbH";"gasse 3";"5000";"Mon";"";"0456";"45652" "Firma";"";"ADAC";"";"50000";"Mon";"";"2156";"545218"