i'w wondering whether there is a difference between fstream and stdio.h when processing a file with these data

10 10 
P

with fstream it's easier to get the data since with stdio.h i'd need to get every single char and number with getc() and translate i t into whole numbers like 10 am i right ? is there another function in stdio.h to make things a lot easier and faster ?


please if there is even a slight difference tell me

thanx in advance

Recommended Answers

All 6 Replies

> i'w wondering whether there is a difference between fstream and stdio.h
One is C++, the other is C

> i'd need to get every single char and number with getc() and translate i t into whole numbers like 10 am i right ?
It's one way, not the only way.

> is there another function in stdio.h to make things a lot easier and faster ?
fscanf - easy to get going, but hard to make secure.
fgets + strtod / strrol / strtoul - a bit more work, but very safe.

can anyone give me a simple example of what Salem hsa mentioned for example with fscanf

thanx

is stdio.h in this example with this file faster then fstream ?

It should be noted that short of speed, you really need to consider how safe fprintf is. Just remember that read chuncks of data at a time is somewhat faster than reading 1 bye at a time

Chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.