If you use an array to store all those stations and 'for loops' to read from it, it'll make it so much easier to print/read from them
C++ Tutorial - 10 - Beginning Arrays - YouTube
once you...
Type: Posts; User: val3ri3
If you use an array to store all those stations and 'for loops' to read from it, it'll make it so much easier to print/read from them
C++ Tutorial - 10 - Beginning Arrays - YouTube
once you...
Solution
This worked just fine. The mistake was coming from main. Minor error was ruining my read before i even called it. don't i feel embarrassed. but glad it really wasn't my read function
...
Its not working out
-858993460 -858993460
-858993460 -858993460
-858993460 -858993460
Press any key to continue . . .
thats my output i took off the read
Yes exactly like that! I'm going over the link and changed my loop, but having a little trouble adjusting. Output still the same Changing my code as you read
I do know that my program gets into my file because the "read file" does come up on my output but the values i get along with it are not the same values that i should be getting.
What i needed is...
My txt file im trying to read from is formatted like this
619847GBE 641 998
418712IMB 107 867
227451GEM 789 181
981836KEA 747 171
986516IGU 303 71
i need to read data from my txt file and iv got another function to print, but something must be wrong with my read function b/c my values turn out to be random negatives
read function
int...
Found my mistake! Post to come
I kept putting it back as a desperate attempt hoping it would read through the file, but no. I've yet to find the mistake and im using classes
So here is an updated code
here's MAIN
#include "inventory.txt"
#include "myfile.h"
#include <iostream>
#include <string>
#include <fstream>
my fault thought it better not to post the full code but i should have here is main
#include "myfile.h"
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
let me post you more of the code so you can see
sorry posted that last one twice and ok i just removed it
#include "myfile.h"
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
main
#include "inventory.txt"
#include "myfile.h"
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
Feels like it's right in front of me and i don't see it
MAIN
#include "inventory.txt"
#include "myfile.h"
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
Yes i fixed that my code looks cleaner, but im still getting my same error
void read(struct Item Itemlist[], string filename)
{
std::ifstream infile("filename.txt");
std::ofstream outfile("filename.txt");
infile.open("filename");
for(int i=0; i<Max; i++)
Ok so this is what i have now in main
#include "inventory.txt"
#include "myfile.h"
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
Ah sorry haha
and Thanks so much
Problem is im still getting the error i think it's my read function
Please Look On my code.. Is that what you meant for me to do?
In my main?
yea woah actually i accidentaly erased it when i copied the code on here but its on my code let me fix that
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
const int Max=100;