hello all i have the following file
#NB_OF_USERS_PAIRS
3
1 2 2
2 5 6
9 4 3
#NB_OF_EDGE_PAIRS
2
2 2 3
3 2 3
#NB_OF_PEERING_PAIRS
2
4
5
i want to write a program that don't read the #nbof... blah blah. i want it to read the numbers after it, this number represent how man rows are after it, for example in the first line i have 3 this means that i will have 3 rows after it which are
1 2 2
2 5 6
9 4 3
another thing i want it to do is that the these rows i want to put then in struct user ... like the following
for example let use take the first row
1 is in user.nbofuserpairs[i]
2 is in user.nbofuserlinks1[i]
2 is in user.nbofuserlinks2[i]
...
i wrote the following program to read the first 5 lines in the file.txt can you help me???
the program i wrote is
#include<conio.h>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <string>
using std::string;
struct user{
int nbofuserspairs[];
char userplayernumber[];
int nboflinks1[];
int nboflinks2[];
int nbofstrategies;
int selfcost;
int dummycost;
int delay;
};
struct edge{
int nbofedgespairs;
char edgeplayernumber;
int nboflinks;
int nbofstrategies;
int selfcost;
int dummycost;
int diversity;
};
struct peer{
int nbofpeerspairs;
char peerplayernumber;
int nboflinks;
int nbofstrategies;
int selfcost;
int dummycost;
int congestioncost;
};
void read_file(string ASfile);
void main(){
user users;
string ASfile("dataset1.txt");
read_file(ASfile);
int i=0;
for(i=0;i<users.nbofuserspairs;i++)
printf("nbofusers %d nboflinks1 %d nboflinks2 %d",users.nbofuserspairs[i],users.nboflinks1[i],users.nboflinks2[i]);
getch();}
void read_file(string ASfile){
char bufzone[50]; int bufzon;
FILE* fid;
int i=0;
FILE* fid1;
user users;
fid1=fopen("reslut.txt","w");
fid=fopen(ASfile.c_str(),"r");
if(fid==NULL)
{printf("the file is empty");
}
else
{