I want to input the following lines from file("input.txt") :
a 1,2,3,4,5,6
b 1,8
(i.e a character followed by a white-space and then an array separated by comma)
I have tried following code:
int main(int argc, char *argv[])
{
std::vector<int> arr;
FILE *file = fopen("input.txt","r");
while(!feof(file))
{
for(int i = 0; i < arr.size(); i++)
{
fscanf(file,"%s %d,",str,&arr[i]);
}
}
}
Let me know correct way to doing this, as it is showing garbage values