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

C fscanf- how to skip lines

19
I'm making a little program to track what items I sell/buy how much of them how much it was to buy it and when I bought it. This program is only C (or trying to keep it that way)

Theres a few files that im writing to to display all that information, but that's for another time.

This post is to ask how to read from one of the files (it brings in "All Sessions" data)

the file looks like this

Expand|Select|Wrap|Line Numbers
  1.           Last Session
  2.          --------------
  3. Buy:                       111111
  4. Sell:                      222222
  5. =================================
  6. Net:                       111111
  7.  
  8.  
  9.  
  10.           All Sessions
  11.          --------------
  12. Buy:                       222222
  13. Sell:                      444444
  14. =================================
  15. Net:                       222222
(cant seem to get the "Last Session" but it's suppose to be 10 spaces over)

So I need to know how I can skip the first 10 lines to bring in the 3 totals (buy sell and net)

The format never changes.
Jul 21 '08 #1
2 9784
gpraghuram
1,275 Expert 1GB
Hi,
If you want to skip 10 lines always then what u can do is
1)Open the file
2)use fgets to read a line
3)Loop using fgets tiil u read 10 lines
4)Then u can use fscanf to start processing from 11th line


Raghu
Jul 21 '08 #2
odin607
19
thanks

This Problem: Solved- but open for other possible answers
Jul 21 '08 #3

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

Similar topics

22
by: John Phung | last post by:
Is there a fscanf equivalent for c++? Here's what I'm talking about: unsigned int NextAddress(ifstream& AddressFile) { unsigned int next_address; -->How do I rewrite the fscanf listed below...
7
by: Thomas Sourmail | last post by:
Hi, I hope I am missing something simple, but.. here is my problem: I need my program to check the last column of a file, as in : a b c d target ref 0 0 0 0 1 a 1 0 0 0 1.5 b 2 0 0 0 2 c
3
by: totoro2468 | last post by:
Hi, I'm a complete NOOB. How do I get fscanf to copy into an array? I also need to use malloc, but where do I put it in my file? _______________________________________________________ FILE...
9
by: quyvle | last post by:
I can't seem to get this function to work correctly. I'm wondering if anyone could help me out with this. So I'm using the fscanf function to read the input stream and store each string in the...
9
by: kvnsmnsn | last post by:
Over the course of my career I've transitioned from an Ada programmer (am I dating myself?) to a C programmer to a Java programmer and now back to a C programmer with the job I've currently...
13
by: PeterOut | last post by:
I am using MS Visual C++ 6.0 on Windows XP 5.1 (SP2). I am not sure if this is a C, C++ or MS issue but fscanf has been randomly hanging on me. I make the call hundreds, if not thousands, of...
10
by: rsk | last post by:
Hi Friends, I have written a code which suppose to read all the numbers from a hex file,But to my surprise the code is skiping every alternate value.Don't know why? Can you please help me in...
59
by: David Mathog | last post by:
Apologies if this is in the FAQ. I looked, but didn't find it. In a particular program the input read from a file is supposed to be: + 100 200 name1 - 101 201 name2 It is parsed by reading...
1
momotaro
by: momotaro | last post by:
I have a small problem with the last fscanf in this function...every thing is logic in there but can't find the problem... plz help node *BuildGraph() { int range, vehicules, i, j,...
42
by: Bill Cunningham | last post by:
I'm doing something wrong and all I know to do is turn to clc. I have a text file containing 2 doubles separated by a tab. ..26 0 Is the text. I want to read the two double and printf them...
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...
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
marktang
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,...
0
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...
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
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.