473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Read text file

i am a long time unix user of C++, but bc of issues at my company i can
only get to use Visual C++. Can anyone give me simple code on reading
data from a text file. my C++ methods arent supported
thanks

Aug 4 '06 #1
7 2180

ianadels...@lycos.com wrote:
i am a long time unix user of C++, but bc of issues at my company i can
only get to use Visual C++. Can anyone give me simple code on reading
data from a text file. my C++ methods arent supported
thanks
The standard way should work. An fstream is an fstream.

Aug 4 '06 #2
ianadels...@lycos.com wrote:
i am a long time unix user of C++, but bc of issues at my company i can
only get to use Visual C++. Can anyone give me simple code on reading
data from a text file. my C++ methods arent supported
What standard C++ I/O techniques aren't supported in VC++?

Cheers! --M

Aug 4 '06 #3

<ia*********@lycos.coma écrit dans le message de news:
11**********************@h48g2000cwc.googlegroups. com...
>i am a long time unix user of C++, but bc of issues at my company i can
only get to use Visual C++. Can anyone give me simple code on reading
data from a text file. my C++ methods arent supported
thanks
#include <fstream>
#include <string>
#include <iostream>

using namespace std;
int main()
{
ifstream MyFile("data.txt"); // text file by default, check optional
arg for binary
string str;
// print each line of the file on screen
while(getline(MyFile,str))
{
cout << str <<"\n";
}
MyFile.close();
}

Eric
Aug 4 '06 #4
i forgot that im retarded - and the methods are supported and my
headers were screwed up
thanks
mlimber wrote:
ianadels...@lycos.com wrote:
i am a long time unix user of C++, but bc of issues at my company i can
only get to use Visual C++. Can anyone give me simple code on reading
data from a text file. my C++ methods arent supported

What standard C++ I/O techniques aren't supported in VC++?

Cheers! --M
Aug 4 '06 #5
ia*********@lycos.com wrote:
i am a long time unix user of C++, but bc of issues at my company i
can only get to use Visual C++. Can anyone give me simple code on
reading data from a text file. my C++ methods arent supported
thanks

I suspect that the "C++ methods" you refer to are actually POSIX ones
like open(), read(), etc. Those are not C++. Post some example code.


Brian
Aug 4 '06 #6
In article <11**********************@h48g2000cwc.googlegroups .com>,
ia*********@lycos.com wrote:
i am a long time unix user of C++, but bc of issues at my company i can
only get to use Visual C++. Can anyone give me simple code on reading
data from a text file. my C++ methods arent supported
thanks
My guess is you are having an issue with paths. Check in a newsgroup
devoted to Visual C++.
Aug 4 '06 #7
ia*********@lycos.com wrote:
i forgot
See below.

Brian
--
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.htm>
Aug 4 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Flynn | last post by:
hi, having problems reading from and writing back to the same file. basically, i want to read lines of text from a file and reverse them and write them back to the same file.. it has to...
1
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each...
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
3
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its...
3
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT...
3
by: Ray | last post by:
Hello World, I made a Windowsform that reads data from a CSV file. It works fine, but when I have read the data of a record I have to re-Debug the form to read another record. So when I put a...
6
by: Thomas Kowalski | last post by:
Hi, currently I am reading a huge (about 10-100 MB) text-file line by line using fstreams and getline. I wonder whether there is a faster way to read a file line by line (with std::string line)....
6
by: portCo | last post by:
Hello there, I am creating a vb application which is some like like a questionare. Application read a text file which contains many questions and display one question and the input is needed...
0
by: alivip | last post by:
Is python provide search in parent folder contain sub folders and files for example folder name is cars and sub file is Toyota,Honda and BMW and Toyota contain file name camry and file name corola,...
4
by: Keith G Hicks | last post by:
I'm trying to read a text file and alter the contents of specific lines in the file. I know how to use streamreader to read each line of a file. I'm doing that already to get the data into a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.