Home Posts Topics Members FAQ
Curten
13 New Member
Hi,
I have just started using C++ (Borland compiler) and I want to read the data in a .txt-file. The txt file looks like this:
Arg 2 12.87
His 25 7.4
His 29 6.9
I would like to put the data in a struct {string, integer, float} where the rows in the struct are the same as the rows in the file. How can I do that?
I know how to read the lines (using getline) from a txt file, but not how to extract theinteger and float numbers from the string.
Thanks for the help!
Sep 26 '06 #1
Subscribe Reply
1 2022
Banfa 9,065 Recognized Expert Moderator Expert
look up the functions
strtol
strtof
or the C++ way would be to verify the string data is correct and create a string stream then just use the >> operators to get int and float data.
Sep 27 '06 #2
reply
Sign in to post your reply or Sign up for a free account.
Similar topics
5 2990 Beginner requesting help - Segmentation fault by: Fra-it |last post by: Hi everybody, I'm trying to make the following code running properly, but I can't get rid of the "SEGMENTATION FAULT" error message when executing. Reading some messages posted earlier, I understood that a segmentation fault can occur whenever I declare a pointer and I leave it un-initialized. So I thought the problem here is with the (const char *)s in the stuct flightData (please note that I get the same fault declaring as char * the... C / C++ |
12 1881 Confused beginner by: Blaze |last post by: I am doing the first walk through on the Visual Studio .Net walkthrough book to learn a little about programming. I am having issues with the first tutorial not running correctly. It seems that the build fails with what the book tells me to do. Specifically, I am doing this: public authors1 GetAuthors() { authors1 authors = new Authors1(); C# / C Sharp |
6 1385 XML formatting to HTML...beginner question by: acs974 |last post by: Hi, I apologize if I am posting this in the wrong forum. I am creating a .net 2.0 website using vb.net. I have an XML file with the following general format: <LearningObjectives> <lo number = '1'> <Title>First Learning Objective. Click for more details</Title> <details>These are the details for LO 1</details> </lo> <lo number = '2'> .NET Framework |
6 2996 beginner questions on embedding/extending python with C++ by: Qun Cao |last post by: Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python interface is providing a convenient scripting toolkit for the application. One example is that a user can write a python script like: player = Player() game.loadPlayer(player) player.moveTo(location) Python |
2 1836 File reading and deleting a pattern (beginner) by: fool |last post by: Dear group, I am a beginner in php and I was little bit experience in C language. I want to read a file's content and delete the first line of the file and display those lines which has got deleted. The content of the external file , which is in .cvs format is: ------------------------------------------------------------------- PHP |
2 1615 beginner needs help by: stargate03 |last post by: Hi there I have a MYSQL database which has the following table CREATE TABLE `#__content` ( `id` int(11) unsigned NOT NULL auto_increment, `title` varchar(100) NOT NULL default '', `title_alias` varchar(100) NOT NULL default '', `introtext` mediumtext NOT NULL, MySQL Database |
2 201 Beginner Question by: Daniel |last post by: Looking for a good resource for beginners? books, online anything that will get me started.. what im trying to focus on is building a small program in c# to look thru a few files in a folder that contain certain words / messages ( i know that is probably more than a beginner can do right off the bat ) but i have other programmers available that can help, but rather try myself before i get them involved.. example of what i mean C# / C Sharp |
3 2033 Write a file - beginner's question by: Ben Keshet |last post by: I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but might have gotten the syntax wrong. the variable I want to write is a line from a file I am reading: "... f = open('receptor.mol2', 'r') line = f.readline() Python |
22 18133 Beginner Projects by: ddg_linux |last post by: I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php programmer and looking for a starting point in regards to practical projects to work on. What are some projects that beginner programmers usually start with? Please list a few that would be good for a beginner PHP programmer to PHP |
8304
What is ONU? by: marktang |last post by: ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of... General |
8238 Changing the language in Windows 10 by: Hystou |last post by: Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,... Windows Server |
8734
Problem With Comparison Operator <=> in G++ 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in... C / C++ |
8672
Maximizing Business Potential: The Nexus of Website Design and Digital Marketing 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is... Online Marketing |
1 6138
Access Europe - Using VBA to create a class based on a table - Wed 1 May 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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will... Microsoft Access / VBA |
5591 Couldnt get equations in html when convert word .docx file to html file in C#. by: conductexam |last post by: I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();... C# / C Sharp |
4117 Trying to create a lan-to-lan vpn between two differents networks by: TSSRALBI |last post by: Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls... Networking - Hardware / Configuration |
1 2660 transfer the data from one system to another through ip address by: 6302768590 |last post by: Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system C# / C Sharp |
2 1547
Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy by: bsmnconsultancy |last post by: In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive... General |
By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.
To disable or enable advertisem*nts and analytics tracking please visit the page.