473,385 Members | 1,341 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,385 software developers and data experts.

how to store data

nurulshidanoni
i hava a data

student id examcode
1 002
006
001
2 123
589

How to store data when it have two data in 1 foleslike above? in .txt ot .cpp?

and how can c++ called the data?
Jan 17 '08 #1
3 1617
gpraghuram
1,275 Expert 1GB
i hava a data

student id examcode
1 002
006
001
2 123
589

How to store data when it have two data in 1 foleslike above? in .txt ot .cpp?

and how can c++ called the data?

Hi,
I cant understand your requirement.
Are you asking how to read the data from the .txt file in the cpp program?
or how to write that infor from cpp to a .txt file?

Raghuram
Jan 17 '08 #2
Expand|Select|Wrap|Line Numbers
  1.  
  2. #include<iostream>
  3. #include<fstream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.             ifstream stream1("Standrews83.txt");
  9.             char a[139];
  10.             if(!stream1)
  11. {
  12.             cout << "While opening a file an error is encountered" << endl;
  13. }
  14.             else
  15. {
  16.             cout << "File is successfully opened" << endl;
  17. }
  18.            while(!stream1.eof())
  19. {
  20.            stream1 >> a;
  21.            cout << a << endl;
  22. }
  23.            return(0);
  24.  
  25. }
  26.  
  27.  

I do like this, but how can the programming detect the data which one is student id and examcode?
Jan 17 '08 #3
sicarie
4,677 Expert Mod 4TB
I do like this, but how can the programming detect the data which one is student id and examcode?
You have to take a look at the file. How can you tell which data is Student ID and which is cxamcode?

It looks like the examcode changes when there are two numbers on one line, and it is the first, and the second is the Student ID. So, you would need to know how strings are terminated (so that you can test for an end of string after a number, or a space), and how to parse the data that you are bringing in (and how you are going to bring it in).
Jan 17 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into...
7
by: Jenny | last post by:
Hi, I have a class foo which will construct some objects in my code. some of the objects store int values into the data deque, while others store float values to the deque. template <class...
0
by: Harley | last post by:
I am trying to write a personal app to keep a bank balance and history. The problem I'm haveing is finding a decent way to store the data on a pocketpc under .net compact framewok useing vb.net....
0
by: sajenia | last post by:
i need to design a solid data store device. the prime use of the data store is to store text messages, with each message being structured as a linked list. the logical concept of the store will be a...
0
by: Brian Vanderburg II | last post by:
Lance Gamet wrote: Lance Gamet wrote: One way I've just started to use it to create a utility function to return the location of the user data folder, depending on the operating system: import...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.