C++ Programming [10] - File Input (Reading Text Files)
Uploader Comments (MrCppHelp)
All Comments (20)
-
I'm new to programming - how can I code a program that can access an excel file, instead of a text file, then be able to compare its string or int contents? Fors instance an excel file would contain some pc names; if one already exist then result of the comparison would come up saying something like "already exists". Thanks -Rob
-
Thanks, good short tutorial.
-
As below would it be possible for you to do a tutorial on using more than one column of data?
-
Hi MrCPPHelp,
Thanks for the great tutorial.
I was wondering if you could do a similar video on txt files containing multiple columns of data. Is the procedure to append separate columns to different arrays much different to what you are doing here?
-
thank's$
-
8 students didn't pass the exam? Shame on them..
-
This was very helpful, now my goal is to read a file into an array like this one but instead all the numbers are in the same line and i have to sort them out. How would you go about doing this. I was thinking of a newline function then bubble sorting them. Any advice would be greatful, Thanks.
-
Hi, I have a question to ask. Do you know how i can delete data that i have written to a text file through the program?
-
@MrCppHelp Hey thanks that would be a real help. I'll be looking forward to your tutorial video.
Hi, I've tried exactly the same thing that you've done in your video but I'm encountering some errors. I modified your program so that it won't input 10 data members of 'string' type from a text file. The program compiles but when i run it, all i see are an infinite number of '0's being outputted. Can you shed some light on this matter? Do i have to make any major changes to the program so it can read 'string' data type?
JonathanCZH 1 year ago
@JonathanCZH Reading it as a "string" is a completely different animal. I'd prefer using char arrays instead. I'll actually make a video on string input since there's some more steps you have to take.
MrCppHelp 1 year ago
Why all c++ examples are in console application????
Gevor92 1 year ago
@Gevor92 how else would you want it shown? if you have any ideas for future tutorials just send me an e mail..
MrCppHelp 1 year ago
how do you calculate the average from numbers in an input file (my input file has 15 numbers)
Johnnyboyinthehouse 1 year ago
@Johnnyboyinthehouse Well since you're using an integer array, add up all the values each time you read a line from the file. When the eof (end of file) is reached, divide it by the value of the counter. The counter should add one (counter++) each time the line is read.
MrCppHelp 1 year ago