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

file Input question

Alright, I have a program I am working on and I want it so it opens a file, and it grabs the first word from each line. I am using a while statement to do this, but I can't figure out how to tell the while statement to go to the next line, it will just grab the next word of the sentence. Any suggestions?
Mar 31 '08 #1
1 1118
gpraghuram
1,275 Expert 1GB
Alright, I have a program I am working on and I want it so it opens a file, and it grabs the first word from each line. I am using a while statement to do this, but I can't figure out how to tell the while statement to go to the next line, it will just grab the next word of the sentence. Any suggestions?

If you read using fgets then it will read a full line.
After reading it use sscanf to get the first word from the read string.
If you do a fgets again it will read the next line in the file and do the process again

Raghuram
Mar 31 '08 #2

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

Similar topics

1
by: Pamela Chatterjee | last post by:
In my project I am uploading file, using HttpPostedFile in ASP.NET. In my project I have to allow user to upload pdf, gif and jepg file only. I know after uploading file I can check ContentType of ...
6
by: a | last post by:
(I've reached that familiar place where I've got a nagging little problem in a program I'm writing but I've been staring at code for too long and I probably wouldn't be able to recognize the answer...
2
by: J.R | last post by:
Greetings, I'm adding dynamically created input type='file' controls via JavaScript. However when I try to access they do not seem to be returned in the form collection. Any ideas? Thanks,...
2
by: Jim Witte | last post by:
Hi, How do I set a file input element? If it's a text input, I can set the value property. But this doesn't work with file inputs. And no, I can't change it - I'm writing a script to...
6
by: tshad | last post by:
I have an upload file input as: <input id="MyFile" style="width:300px" type="File" runat="Server"> This works fine, but I find that if my page doesn't pass validation during postback, the page...
0
by: GB | last post by:
Help needed: in the C++ code of Backprapagation I am using data in the way shwon below. I need to change the program, so that it reads same data (actually I need to put more complex data, for 64...
3
by: masterofzen | last post by:
Hi, everybody, Got a question that's completely perplexing me. I'm developing a site that uses a universal (or "star") selector on a global level, for many different pages. The star selector...
8
by: sore eyes | last post by:
Hi I just downloaded the free Watcom compiler and am having a little trouble with File IO http://www.openwatcom.org/index.php/Download I downloaded the following example, commented out the...
3
by: JackC | last post by:
Hi, Im having some problems working out how I can read the last 5 bytes of a file which i already have open. Heres what i have tried: pFile = fopen ("/home/jc/data.txt" , "rw"); // Some IO...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.