473,397 Members | 2,033 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,397 software developers and data experts.

Getting an Input from the FILE

i have a text file which have the following content
n:=9
name:=vinu

here i need to take the value of n 9 and also value of name vinu
then i need to process and i need to again write in a file as the output

can u just help me out to take the value from a text file
can u just give me a sample code
Feb 20 '07 #1
2 1664
i have a text file which have the following content
n:=9
name:=vinu

here i need to take the value of n 9 and also value of name vinu
then i need to process and i need to again write in a file as the output

can u just help me out to take the value from a text file
can u just give me a sample code
you can use getline comand to get the content of the text file. You should include the fstream header and std:: ifstream for reading text file and std:: oftream for writing text file. You can try to get the content of the file character by character then compare them, using string compare and if it matches write it to your file, or just print them out. I'm also a beginner but I think that should work.
Feb 20 '07 #2
AdrianH
1,251 Expert 1GB
i have a text file which have the following content
n:=9
name:=vinu

here i need to take the value of n 9 and also value of name vinu
then i need to process and i need to again write in a file as the output
Ok.
can u just help me out to take the value from a text file
can u just give me a sample code
No, we cannot. We are not here to do your work for you, but we can give you pointers.

You will need to open an fstream to read the file. In fact, since you are only wanting to read you should use ifstream.

From there you will have to start to read and interpret the input (this is called parsing). Given the nature of the assignment I think part of what stealwings suggested is a good call in that you read in the line. Once read in, you can assign it to a string class object and use find on it or use strstr or strspn on the buffer directly to separate the words from the assignment operator ‘:=’ in your file.

Give it a try and let us know how you are doing. If you have additional questions, feel free to ask. If you are having problems, post the relevant code (within [code] [/code] tags please) and point out where you are having the trouble and what that trouble is.

Good luck,


Adrian
Feb 20 '07 #3

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

Similar topics

0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
10
by: eggie5 | last post by:
Is it possible to get a file without using a form post? I want to get the data (bytes) of a file, text or binary, and just save it to a variable. Similar to the post body of a form that has a...
5
by: olaamussah | last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this...
6
by: sathyashrayan | last post by:
Dear Group, Please look at the following demo link. http://www.itsravi.com/demo/new_pms/admin/addproject.php
3
by: Rainy | last post by:
Hello! I'm having some trouble with pyserial package, I'm sending commands and reading responses from a custom pcb, and sometimes I get a proper response, at other times I get nothing, and...
6
by: passionateforjava | last post by:
Hi All, I am using struts application wherein I need to import file for some purpose.I have used input type="file" for the same which goes like: <input type="file" id="uploadFile" name="uploadFile"...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
9
vikas251074
by: vikas251074 | last post by:
I am not getting date value in spite of my good effort. This code was working in my last office where I work. Now I am trying to work at my home pc. but not getting date value. Any can help me why...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.