| | |
File Mainipulation
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I am extremely new to C++ and I've been trying to do a few things.
I want to read a file and get all the numeric values. This information is going to be used in writing a binary file. I also want to count how many numeric values where found.
Next I want to create a binary file and use each of the seperate numeric values to insert the value into a binary string at a exact offset.
So something like this number.txt includes
1 - blah
2 - blah blah
3 - blah blah blah
program then takes the numbers out
1,2,3
then writes at offset 150 a list of numbers already pre-determined and puts first number found from the number.txt into the offset that is also predetermined and just repeats this process all the way through every number.
1- (offset 150 start here)010101001(insert here offset 10 insert numeric value here)01010
2- (offset 150 start here)010101001(insert here offset 10 insert numeric value here)01010
3- (offset 150 start here)010101001(insert here offset 10 insert numeric value here)01010
Any help is appreciated.
I want to read a file and get all the numeric values. This information is going to be used in writing a binary file. I also want to count how many numeric values where found.
Next I want to create a binary file and use each of the seperate numeric values to insert the value into a binary string at a exact offset.
So something like this number.txt includes
1 - blah
2 - blah blah
3 - blah blah blah
program then takes the numbers out
1,2,3
then writes at offset 150 a list of numbers already pre-determined and puts first number found from the number.txt into the offset that is also predetermined and just repeats this process all the way through every number.
1- (offset 150 start here)010101001(insert here offset 10 insert numeric value here)01010
2- (offset 150 start here)010101001(insert here offset 10 insert numeric value here)01010
3- (offset 150 start here)010101001(insert here offset 10 insert numeric value here)01010
Any help is appreciated.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Is what I have for reading and displaying the file but I dont know how to extract the numbers. I know I could place them in some kind of array I just cant find the command.
[PHP]
int readnumber(){
fstream infile;
infile.open (path, fstream::in);
while (infile.good())
cout << (char) infile.get();
infile.close();
return 0;
}[/PHP]
[PHP]
int readnumber(){
fstream infile;
infile.open (path, fstream::in);
while (infile.good())
cout << (char) infile.get();
infile.close();
return 0;
}[/PHP]
Sorry for the double post but ive been looking through functions and websites trying to figure out something I could just ask somebody else.
http://publib.boulder.ibm.com/infoce...2/gtpc2m02.htm
http://publib.boulder.ibm.com/infoce...2/gtpc2m02.htm
Perhaps read the input file a line at a time using a
string and getline. Then parse the line of text: you could use stringstreams, but I might go with sscanf. "One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- connect to text file database (Visual Basic 4 / 5 / 6)
- Importing SQL Script File - Urgent !! (Database Design)
- enabling file sharing (Windows NT / 2000 / XP)
- 81TB File Server (Networking Hardware Configuration)
Other Threads in the C++ Forum
- Previous Thread: Constrcutors and Destructors
- Next Thread: Connectivity in C
Views: 1079 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






