![]() |
|
#1
|
|||
|
|||
help{
int m[25][3]; int i=0; int j=0; ifstream fin; fin.open("try1.txt"); if (fin.fail()) { cout << "ERROR opening file."; } else { while (!fin.eof()) { fin >> m[j]; Error in this line j++; } } for (int k=0;k<25;k++) {for(int j=0;j<3;j++) { cout << m[k][j] << "\t"; } cout << endl; } } the error is "no operator defined which takes a left-hand operand of type 'class ifstream' (or there is no acceptable conversion) Error executing " |
|||
|
#2
|
||||
|
||||
Re: helpHi rajusb,
Please read the Guidelines. If you insert your code between [c++] and [/c++] tags, that would be very useful for us. and please dont double post. Thank You. You have made good progress in this program. But, the error came because you declared m as: CPP / C++ / C Code:
CPP / C++ / C Code:
So, what you should do is to do something like this: CPP / C++ / C Code:
But using operator >> always result in some scanning error. So, we can get a whole line from the file at a time, then scan the files from the line. Consider that you have a file say try1.txt. The contents is: Code:
Here is a sample C++ program to read from the file and print it: CPP / C++ / C Code:
Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. Last edited by Paramesh : 23-Nov-2005 at 08:55.
|
|
#3
|
|||
|
|||
Re: helpHi,
Thanks a lot. sorry i wanted to write comments! I dont know why i am not getting the output. i am not getting error also.after this it should prit the textfile right but i am not getting that! hope i am not bothering u much. I am writting this in vc++ |
|
#4
|
||||
|
||||
Re: helpHi rajusb,
Did you create and save the file try1.txt as: Code:
Then it will print correctly. Just copy and paste this content in notepad and save it as try1. (what a coincidence that we both are online in the same time!) ![]() Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#5
|
|||
|
|||
Re: helpYa, we r online on the same time. I have saved in my file but i am not getting the output?
|
|
#6
|
||||
|
||||
Re: helpQuote:
Did you get any error message? __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#7
|
|||
|
|||
Re: helpya in my file. I am not getting any error message
|
|
#8
|
|||
|
|||
Re: helpI have written the code in OnLBUTTONDOWN, Its showing the window,I have written in ONDRAW,Press the LBUTTONDOWN but its not displaying anything
|
|
#9
|
||||
|
||||
Re: helpQuote:
The code i showed you is a console program. Not a windows program. That was a sample program. Just to give you some information about how to read from a text file. If you want to write a windows program, Just remove the cout statements and then use the arrays to display in a windows component(may be try a textbox to display one value first.) Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#10
|
|||
|
|||
Re: helpya ok let me read a first row and first column for that if use array then to print please can u do for me to read first row and first column please!!!!
11 23 4.56 3.54 9.56 45 56 34 65 67 9.65 9.89 8.65 23 3.56 67 76 87 6.78 |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The