Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 11-16-2003, 03:26 PM   #1
Beta Member
 
Join Date: Nov 2003
Posts: 3
Send a message via AIM to snyppl
Question Need help in c++...???

Can someone help me in file management to search for a string in a text file, also I would like to see if there are multiple same strings in the file and delete one so there is one instance of that string.
__________________

snyppl is offline   Reply With Quote
Old 11-16-2003, 03:32 PM   #2
Site Team
 
David Lindon's Avatar
 
Join Date: Dec 2002
Posts: 15,233
Default Re: Need help in c++...???

Sorry, I am a bit of a C++ noob myslef so I can't help you. Maybe you can help me, what complier do you use?
__________________

__________________
[url=http://www.LNXPS.NET]LNXPS.NET - The XPS Library]
David Lindon is offline   Reply With Quote
Old 11-16-2003, 03:44 PM   #3
In Runtime
 
XtremeWarrior's Avatar
 
Join Date: Sep 2003
Posts: 102
Send a message via ICQ to XtremeWarrior
Default Re: Need help in c++...???

I'm also a newbie so I only know how to make a "Hello World !"
XtremeWarrior is offline   Reply With Quote
Old 11-16-2003, 05:08 PM   #4
Beta Member
 
Join Date: Nov 2003
Posts: 3
Send a message via AIM to snyppl
Default The help...

I use Microsoft Visual Studio 6 Enterprise Edition. (If you have a Microsoft C++ compiler, preferred 6) then I can help you:
A small program.
#include <iostream>
using namespace std;

main()
{
char i = 'a';

for (i = 'a';i<='z';i++)
cout << i;
cout <<endl;
system("pause");

return 0;
}
snyppl is offline   Reply With Quote
Old 11-16-2003, 05:41 PM   #5
Site Team
 
David Lindon's Avatar
 
Join Date: Dec 2002
Posts: 15,233
Default Re: Need help in c++...???

Thank you.
__________________
[url=http://www.LNXPS.NET]LNXPS.NET - The XPS Library]
David Lindon is offline   Reply With Quote
Old 11-17-2003, 04:27 AM   #6
Baseband Member
 
Join Date: Sep 2003
Posts: 67
Default

I've done some relatively heavy studies on C++ the language, the only problem is; I don't acctually know how to do anything. I really only know how to use IOstreams cout; and cin;
it's truely horrible,

got any suggestions for good libraries to learn (and some useful URLS?), I'd be very interested to learn how to write file accessing prorgams. maybe a program that writes a .txt file, now that'd be cool.

another thing I am very interested in is talking to the command line realtime, know anything about that?

RC
Reiken is offline   Reply With Quote
Old 11-17-2003, 07:40 PM   #7
Beta Member
 
Join Date: Nov 2003
Posts: 3
Send a message via AIM to snyppl
Cool If any need help, just e-Mail me

AT snyp_@hotmail.com
snyppl is offline   Reply With Quote
Old 02-01-2004, 08:57 PM   #8
Baseband Member
 
Join Date: Feb 2004
Posts: 32
Send a message via AIM to Traveller
Default

Their are a number of good boards out there for dealing with C++. Two that I frequent often and have found to be very useful are:

www.cprogramming.com
www.cpp-home.com

The people are very friendly and both sites have alot of tutorials and source code.
Traveller is offline   Reply With Quote
Old 02-02-2004, 11:15 AM   #9
Site Team
 
David Lindon's Avatar
 
Join Date: Dec 2002
Posts: 15,233
Default Re: Need help in c++...???

Yeah, cpp-home is very good.
__________________
[url=http://www.LNXPS.NET]LNXPS.NET - The XPS Library]
David Lindon is offline   Reply With Quote
Old 02-03-2004, 06:36 PM   #10
Baseband Member
 
Join Date: Feb 2004
Posts: 32
Send a message via AIM to Traveller
Default

The quickest and easiest way to write to text files in C++ is with the fstream object. Now, the best way is with CreateFile and WriteFile, APIs however they require more explaination and are more difficult to use.

An example of file i/o using the fstream objects is this:
Code:
#include <iostream>
#include <fstream>

using namespace std;

int main(){
	
	char filename[20];
	char filein;

	cout<<"Enter the name of the file you want to create: ";
	cin>>filename;

	ofstream fOut(filename); //create file object

	fOut<<"This is your text file"; //write to file
	fOut.close();

	ifstream fIn(filename); //open file
	cout<<"This is what your file contains:\n";
	while(fIn.get(filein)){ //input from file
		cout<<filein;
	}
	fIn.close();

	cin.get();// removes remaining keystroke (yes flush() works and their are many other methods but I used this)
	cin.get(); //wait to display output
	return(0);
}
That will get you started right away, however if you want to seriously do file I/O, then I recommend using the Win32 APIs.
__________________

Traveller is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 08:26 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0