Connecting Tech Pros Worldwide Forums | Help | Site Map

fstream vs FILE

solarrobor
Guest
 
Posts: n/a
#1: Mar 7 '08
I am currently porting a program from C to C++. The program needs to
read the file "/proc/bus/usb/devices".
I am able to open and read from the file using FILE but not when I use
fstream.

Why does it work with FILE and not fstream?
What is the solution to making it work using fstream?

I am using GCC 4.2.3 on Fedora 8

Victor Bazarov
Guest
 
Posts: n/a
#2: Mar 7 '08

re: fstream vs FILE


solarrobor wrote:
Quote:
I am currently porting a program from C to C++. The program needs to
read the file "/proc/bus/usb/devices".
I am able to open and read from the file using FILE but not when I use
fstream.
>
Why does it work with FILE and not fstream?
Because in your fstream use there is a logical error on line 42.
Quote:
What is the solution to making it work using fstream?
The solution is usually to fix the problem. Since you didn't tell
us what the problem actually is, how can we help you fix it?

Another possible solution is not to do anything, just keep using
FILE pointers and you should be OK.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Christopher
Guest
 
Posts: n/a
#3: Mar 7 '08

re: fstream vs FILE


On Mar 7, 12:04 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Quote:
solarrobor wrote:
Quote:
I am currently porting a program from C to C++. The program needs to
read the file "/proc/bus/usb/devices".
I am able to open and read from the file using FILE but not when I use
fstream.
>
Quote:
Why does it work with FILE and not fstream?
>
Because in your fstream use there is a logical error on line 42.
>
Quote:
What is the solution to making it work using fstream?
>
The solution is usually to fix the problem. Since you didn't tell
us what the problem actually is, how can we help you fix it?
>
Another possible solution is not to do anything, just keep using
FILE pointers and you should be OK.
>
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

I have to disagree, Victor. My crystal ball is bigger and shinier and
it says it is line 63.
Victor Bazarov
Guest
 
Posts: n/a
#4: Mar 7 '08

re: fstream vs FILE


Christopher wrote:
Quote:
On Mar 7, 12:04 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Quote:
>solarrobor wrote:
Quote:
>>I am currently porting a program from C to C++. The program needs to
>>read the file "/proc/bus/usb/devices".
>>I am able to open and read from the file using FILE but not when I
>>use fstream.
>>
Quote:
>>Why does it work with FILE and not fstream?
>>
>Because in your fstream use there is a logical error on line 42.
>[..courtesy snip of overquoted material..]
>
I have to disagree, Victor. My crystal ball is bigger and shinier and
it says it is line 63.
Apparently your ball is bigger by exactly 50%... <g>

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Paavo Helde
Guest
 
Posts: n/a
#5: Mar 18 '08

re: fstream vs FILE


solarrobor <franzaklein@yahoo.co.ukwrote in news:e886828b-d88b-4eee-8f71-
fefc6c10c3cd@n77g2000hse.googlegroups.com:
Quote:
I am currently porting a program from C to C++. The program needs to
read the file "/proc/bus/usb/devices".
I am able to open and read from the file using FILE but not when I use
fstream.
Porting C to C++ involves providing function declarations in header files
and some more obscure changes. The FILE* interface is perfectly OK in C++,
so it seems you are probably wasting your employer's money ;-)

NHTH (not hoping this helps... )
Paavo
Closed Thread