Thread: [Dev-C++] [Dec-C++]eof() function and type variable from file input
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: carlos D. M. <cg...@wo...> - 2001-11-10 17:58:28
|
Hi again:
I am writing a program for make a two weeks work in one minute, and it
will take me two months...
I have a .txt archive with various tables of diferent amount of rows,
and always five columns; I need a program which the first five data are
sent to a char * variable; the next 5*n values to a float [5] and write
them in other archive as I need them, after one data which is char *,
made by letters and numbers, being the first a letter.
Well: I try it writing what I must write but:
a) If I use while(!inputFile.eof()){
the body of all the instructions needed
}
When I run the program, immediately,
when it's the moment of reading the inputFile **the program has
generated an error log and it wwill be closed by windows**
b) If I try something like for(as many times as tables it must
pass) I find that it doesn't recognize the type of the data:
The first is a while(inputFile >> charvariable); what i want do with
them; while(inputFile >> floatvariable); what I want do with them, with
the correspondent variable arrays with the suscripts and counters, etc;
and inputFile >> thelastcharofthetable);what I want do; Then I found the
program:
b.1) ***generated error.log bla bla guauau****
b.2) It considered all data as char, and soit did for every data of
the txt file the same, what I want for the first five words.
Are there any function hich lets the program know if the data from input
file is float or char or int and once known use that data for the
correct instruction? Or it is best to do it by hand, killing the
computer and suiciding myself?
I hope this is a problem for be console program, so I will be able to
write the program I think i will need write in the future. But I think,
that although the main are the windows programs, the console ones would
be good to have a good work.
Now I don't need that hard program and it would be very, very useful can
program some little consoles. And if I can write the program five
minutes and do what I need in three seconds (I don't worry very much now
about efficiency, I write for myself) and avoid do it by hand in weeks
of giant boring waste of time.
Thanks to anybody who can help.
Thanks to everybody who will find this message occupying memory, for
their patience.
Thanks if Dev-C++ 5 solve this problems(if it is really a problem of the
progran and not my inexperience) (And thanks either if not).
|
|
From: Jason H. <jas...@bt...> - 2001-11-10 21:15:19
|
No offence, but I'm having trouble working through your english. From what I
can gather you have a file which you need to read through and re-output in a
different format.
If you could provide an example of a valid input file (3 or 4 lines) and the
output file that it would convert to. You don't have to provide actual data,
just make it up if it's confidential. Maybe then we could work up something
that might work.
I don't know of any standard functions that determine for you whether
something is a float, int or string of somesort. It is assumed you would
know the file format or be able to work it out for yourself. It depends upon
how you choose to represent your data in the end.
I am currently working on a program that takes in a file and outputs
something else depending upon the contents of the input file. So all that
needs to be different is the code that deciphers the input and produces the
output.
Also Dev-C++ is just an environment for developing programs, the standard
compiler is MinGW, which isn't totally standards compliant but works well
enough.
Jason.
----- Original Message -----
From: "carlos GARCÍA DEL MONTE" <cg...@wo...>
To: <dev...@li...>
Sent: Saturday, November 10, 2001 6:00 PM
Subject: [Dev-C++] [Dec-C++]eof() function and type variable from file input
> Hi again:
>
> I am writing a program for make a two weeks work in one minute, and it
> will take me two months...
> I have a .txt archive with various tables of diferent amount of rows,
> and always five columns; I need a program which the first five data are
> sent to a char * variable; the next 5*n values to a float [5] and write
> them in other archive as I need them, after one data which is char *,
> made by letters and numbers, being the first a letter.
>
> Well: I try it writing what I must write but:
> a) If I use while(!inputFile.eof()){
> the body of all the instructions needed
> }
> When I run the program, immediately,
> when it's the moment of reading the inputFile **the program has
> generated an error log and it wwill be closed by windows**
> b) If I try something like for(as many times as tables it must
> pass) I find that it doesn't recognize the type of the data:
> The first is a while(inputFile >> charvariable); what i want do with
> them; while(inputFile >> floatvariable); what I want do with them, with
> the correspondent variable arrays with the suscripts and counters, etc;
> and inputFile >> thelastcharofthetable);what I want do; Then I found the
> program:
> b.1) ***generated error.log bla bla guauau****
> b.2) It considered all data as char, and soit did for every data of
> the txt file the same, what I want for the first five words.
>
> Are there any function hich lets the program know if the data from input
> file is float or char or int and once known use that data for the
> correct instruction? Or it is best to do it by hand, killing the
> computer and suiciding myself?
>
> I hope this is a problem for be console program, so I will be able to
> write the program I think i will need write in the future. But I think,
> that although the main are the windows programs, the console ones would
> be good to have a good work.
> Now I don't need that hard program and it would be very, very useful can
> program some little consoles. And if I can write the program five
> minutes and do what I need in three seconds (I don't worry very much now
> about efficiency, I write for myself) and avoid do it by hand in weeks
> of giant boring waste of time.
>
> Thanks to anybody who can help.
> Thanks to everybody who will find this message occupying memory, for
> their patience.
> Thanks if Dev-C++ 5 solve this problems(if it is really a problem of the
> progran and not my inexperience) (And thanks either if not).
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|