| | |
fstream Tutorial
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
•
•
if you output abc123 to a
text file you will see abc123 but in a binary file you may see only a bunch of black
blocks if you use notepad
is it just a cast?
http://sales.carina-e.com
no www
no nonsense
coming soon to a pc near you! :cool:
no www
no nonsense
coming soon to a pc near you! :cool:
•
•
•
•
am doing it without any funds and using a free web tutorial worth crap
btw i forgot to say last time thank you to 'FireNet' for the fstream tutorial. Ive been looking for a good one for a while. is there any advantage into using the Win32 API (FILE) file handling? the win32 help is a bit patchy on the subject..... http://sales.carina-e.com
no www
no nonsense
coming soon to a pc near you! :cool:
no www
no nonsense
coming soon to a pc near you! :cool:
HeHe, im still running into some toruble learning, casue the tutorial doesnt assign home work, and im bad at creating homework on stuff i dun now, so i have to ask one of my 3 freinds who are Programming Wizards, and occasionaly here. I might soon just give up trying to do it by the internet and use a book ;p Altho i dun have the money, ill save up!
I beleive in Technology is the future, and thats were I want to be.
•
•
•
•
Originally Posted by 1o0oBhP
i no how u feel!!! i am self taught, learned by copying code from the help file in QBasic and lookin @ how it worked! having said that i am at a better standard in c++ vb and asm lang than other people i know doing A-levels in the specified subject so hold out as there are some good tuts out there. I have managed to create a few games and even worked as a software developer designing drivers and GUIs in vb just using tutorials and practising a LOT. good job too as part of my engineering masters degree is computer programming and they are using the same IDE as me (DevC++)![]()
btw i forgot to say last time thank you to 'FireNet' for the fstream tutorial. Ive been looking for a good one for a while. is there any advantage into using the Win32 API (FILE) file handling? the win32 help is a bit patchy on the subject.....
Advantages of Win32 API (FILE) file handling, are you kidding,it sucks.... well almost.One of the major problem with it is that it is platform dependent and uses C style functions.
Try this link,http://msdn.microsoft.com/library/de...ling_tasks.asp
Using standard library functions are always better than using API stuff,unless you are doning something really specific, since std library code is cross-platform and will work on any OS which has the compiler.
•
•
•
•
Originally Posted by anastacia
this one was more intersting. keep it up. looking forward for the next part
,it's just that darn message lying at the top.I can remove it since,we cant edit or posts after half an hour.But Just wait till I get my site up properly...
•
•
Join Date: Dec 2004
Posts: 1
Reputation:
Solved Threads: 0
FireNet, this really is a good tutorial.
Here is my problem. I want to read in a file, the file might have x amount of lines, but on each line I would like to read in each substring, which is separated by spaces, and manipulate each.
For example. I would like to read a line which has "A2 3 G4 H5 L4" where A2 is the name of the node, so that needs to be stored in my structure as char type in variable NodeName, plus the number after the initial NodeName, 3 in this case, is the amount of nodes following it, so my program should know how many more nodes to check for. Also, a node can be named A2b or G4h or something, it stops reading the node name when it comes on a space. What is the easiest to go about doing this ?
Here is my problem. I want to read in a file, the file might have x amount of lines, but on each line I would like to read in each substring, which is separated by spaces, and manipulate each.
For example. I would like to read a line which has "A2 3 G4 H5 L4" where A2 is the name of the node, so that needs to be stored in my structure as char type in variable NodeName, plus the number after the initial NodeName, 3 in this case, is the amount of nodes following it, so my program should know how many more nodes to check for. Also, a node can be named A2b or G4h or something, it stops reading the node name when it comes on a space. What is the easiest to go about doing this ?
Have a line at the beginning specifying the number of lines. another alternative is to get the total filesize and divide it by the size of a line... You can then get lines by reading characters and stopping at "\n" chars. There also is a standard c function getline but i dont know how to use it 
As for the sub strings if you have the line in a character string:
im sure it would be easier with a lot more thought, @ the moment its all i can think of. If you add another variable to track where you found the last space you can 'map out' where there are words in a string and also copy them across into another array of sub strings...
post what code you have so far including the structs and the fstream code and one of us should be able to help

As for the sub strings if you have the line in a character string:
C++ Syntax (Toggle Plain Text)
char *line; char x; int i = 0; do { x = line[i]; if(x == ' ') { // you have hit a space, the characters before are a substring } i++; // scan across the line } while (x != "\n"); // dont overrun the line
im sure it would be easier with a lot more thought, @ the moment its all i can think of. If you add another variable to track where you found the last space you can 'map out' where there are words in a string and also copy them across into another array of sub strings...

post what code you have so far including the structs and the fstream code and one of us should be able to help
http://sales.carina-e.com
no www
no nonsense
coming soon to a pc near you! :cool:
no www
no nonsense
coming soon to a pc near you! :cool:
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: C++ Style
- Next Thread: write aprogramme
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





