LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-25-2008, 05:06 PM   #1
technalogist
LQ Newbie
 
Registered: Sep 2008
Posts: 1

Rep: Reputation: Disabled
Smile C++ I/o read file


Hello there i am new to c++ just starting too learn it and i want to make one little program that will read text file and grab a string from that text file and use it as variable. Here is example

I have a text file like this:

Blub blub blub blub
Blub blub blub blub
blub C:\foldername\foldername\filename1.xxx
Blub blub blub blub
Blub blub blub blub
blub C:\foldername\foldername2\filename1.xxx
Blub blub blub blub
Blub blub blub blub
C:\foldername3\foldername\filename1.xxx
Blub blub blub blub
Blub blub blub blub
C:\foldername\foldername4\filename1.xxx

I want to get this path and actually change file attributes and write to this file i know how to do this but i don't know how to get c++ to read this text file and find path. I will be so thankful for any help!
 
Old 09-25-2008, 05:36 PM   #2
cyent
Member
 
Registered: Aug 2001
Location: ChristChurch New Zealand
Distribution: Ubuntu
Posts: 398

Rep: Reputation: 87
Quote:
Originally Posted by technalogist View Post
Hello there i am new to c++ just starting too learn it and i want to make one little program that will read text file and grab a string from that text file and use it as variable. Here is example
Meta answer. Don't use C++ for a task like this. Use ruby or perl or python ( I recommend ruby). You can do it in one line.


What you need to do is read about iostreams, in particular ifstream and std::string.

That should get you started.
 
Old 09-26-2008, 02:45 AM   #3
jb_get
Member
 
Registered: Sep 2008
Location: America
Distribution: Debian
Posts: 33

Rep: Reputation: 16
Since the file pretty much follows the same structure you could set delimiters and get the links like that. Take the time to do it in C, it will make you a better programmer in the end.

Last edited by crabboy; 09-16-2010 at 09:03 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Only File System? Can't read superblock! haughjd Linux - Software 4 01-15-2008 08:27 AM
web server (fedora core 5) became read-only file system after i upload a file nggs8411 Linux - Server 1 03-26-2007 09:23 AM
Java File Processing using Scanner; Can't get it to read file in running directory xemous Programming 2 09-26-2006 06:13 PM
how do I make a read-only file NOT read-only? robster Linux - General 1 02-17-2004 09:11 PM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 07:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration