Question: Hello I am working on a fillArray and printArray methoid but it doesn't grab everything from the .txt file and prints out strange things..here is

Hello I am working on a fillArray and printArray methoid but it doesn't grab everything from the .txt file and prints out strange things..here is what I have and what it prints out and what the .txt file has in it.. if anyone can help. It is using a struct as well so I was told it should be easy but I don't know it has been a bit hard for me.. thank you! (I also might be making this way harder then it should be..) let me know if you need more information

Hello I am working on a fillArray and printArray methoid but it

doesn't grab everything from the .txt file and prints out strange things..here

is what I have and what it prints out and what the

.txt file has in it.. if anyone can help. It is using

int fillArray(Stock array[], FILE * fin) { int total = 0; char strBuffer[100]; double longBuffer; while( ! feof(fin)) { fscanf(fin, format: "%s", strBuffer); strip(strBuffer); if(strlen(strBuffer) != 0) strcpy(array[total].symbol, strBuffer); fscanf(fin, format: "%s", strBuffer); strip(strBuffer); if(strlen(strBuffer) != 0) strcpy(array[total].name, strBuffer); fscanf(fin, format: "elf", &longBuffer); array[total].price = longBuffer; total++; rewind (fin); printArray(array, return total; total: 10); void printArray (Stock array[], int total) { //Prints the company name - symbol - $price to two decimal places printf( format: "%s - % - $%.21f ", array[i].name, array[i].symbol, array[i].price); char symbol[10]; char name[100); double price; typedef struct stock Stock; MSFT Microsoft 53.24 Hillenbrand Inc SCHW Charles Schwab 31.37 GOOG Google 721.11 Lab9 /home/jason/Documents/Lab9/cmake-build-debug/Lab9 Please enter the name of the input file stocks.txt MSFT Microsoft 53.240000 HI Hillenbrand 53.240000 30.65 SCHW 53.240000 Charles Schwab 31.370000 GOOG Google 721.110000 Microsoft - MSFT - 53.24 Hillenbrand - HI - 53.24 Schwab - Charles - 31.37 Google - GOOG - 721.11 - - 0.00 "0 - - 0.00 +"0 - - 0.00 - - 0.00 Process finished with exit code o int fillArray(Stock array[], FILE * fin) { int total = 0; char strBuffer[100]; double longBuffer; while( ! feof(fin)) { fscanf(fin, format: "%s", strBuffer); strip(strBuffer); if(strlen(strBuffer) != 0) strcpy(array[total].symbol, strBuffer); fscanf(fin, format: "%s", strBuffer); strip(strBuffer); if(strlen(strBuffer) != 0) strcpy(array[total].name, strBuffer); fscanf(fin, format: "elf", &longBuffer); array[total].price = longBuffer; total++; rewind (fin); printArray(array, return total; total: 10); void printArray (Stock array[], int total) { //Prints the company name - symbol - $price to two decimal places printf( format: "%s - % - $%.21f ", array[i].name, array[i].symbol, array[i].price); char symbol[10]; char name[100); double price; typedef struct stock Stock; MSFT Microsoft 53.24 Hillenbrand Inc SCHW Charles Schwab 31.37 GOOG Google 721.11 Lab9 /home/jason/Documents/Lab9/cmake-build-debug/Lab9 Please enter the name of the input file stocks.txt MSFT Microsoft 53.240000 HI Hillenbrand 53.240000 30.65 SCHW 53.240000 Charles Schwab 31.370000 GOOG Google 721.110000 Microsoft - MSFT - 53.24 Hillenbrand - HI - 53.24 Schwab - Charles - 31.37 Google - GOOG - 721.11 - - 0.00 "0 - - 0.00 +"0 - - 0.00 - - 0.00 Process finished with exit code o

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!