473,395 Members | 2,446 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 seekg

17
Hi
I have to write a prg for the following question..

A file carsale_june.txt stores the number of small and medium-sized of cars sold in the month of June by a car company. The first line of carsale_june.txt is an integer that indicates the number of carsalemen working in the company. Each row afterwards consists of three data items, namely, the saleman employee id, followed by the number of small-sized and medium-sized cars he sold. A typical carsale_june.txt file is as follows:

4
01107 10 6
08821 5 8
96512 14 6
23115 20 3

Write a program that uses the carsale_june.txt file to print the average number of cars sold in June and the id of the carsaleman who makes a sale higher than the average.


i can create the file then how wat do i do? i think i have to use seekp and seekg koz the 2nd and 3rd column is for number of cars sold
how do i use seekp or seekg? can sumbody explain plzzz
Nov 19 '06 #1
1 2203
sivadhas2006
142 100+
Hi,

You can read the values one by one like this.
And do the calculation to satisfy your need.

Expand|Select|Wrap|Line Numbers
  1. fscanf(fpCarDetails, "%d%d%d", &nEmployeeId, &nSmallCars, &nMediamCars);
  2.  
And also first try to write the program and post it, if you faced any problem.

Regards,
M.Sivadhas.
Nov 20 '06 #2

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

Similar topics

1
by: wtnt | last post by:
Hello. I've searched all over and haven't seen another thread with this problem. Please bear with me as I try to explain. thanks. :) I have some programs that need to be cross-platform...
15
by: SK | last post by:
Hey folks, I am searching for a string (say "ABC") backwards in a file. First I seek to the end. Then I try to make a check like - do { file.clear (); file.get(c); file.seekg(-2,...
10
by: Steve | last post by:
Hi, I'm trying to read a binary file into a buffer: std::ifstream ifs(fileName, std::ios::in|std::ios::binary); if (!ifs) return; ifs.seekg(0,std::ios::end); int len = ifs.tellg();...
3
by: Abhas | last post by:
> > Hi, this is Abhas, > > I had made a video library program in C++, but was facing a problem. > > After entering 12 movies, i cannot enter any more movies. > > Something gibberish comes instead....
10
by: Gunnar G | last post by:
I'm having problem reading from the beginning of a file. Here is the code (more or less) ifstream codefin; ofstream codefout; while (not_annoyed)
9
by: Use*n*x | last post by:
Hello, I have a binary file (image file) and am reading 4-bytes at a time. The File size is 63,480,320 bytes. My assumption is that if I loop through this file reading 4 bytes at a time, I...
3
by: John Williams | last post by:
I'm writing a stagenography program to experiment with how it works. The algorithm I'm using appears to be producing the correct result...however I'm struggling with the file input. I never...
9
by: szclark | last post by:
Hello, I am trying to extract information from a file I have so that I can answer some questions on it, the problem I'm having is that it is returning back mostly gibberish and I really don't know...
1
by: prybrr04 | last post by:
Hello All, I wanted came here to get some advice on reading an input file where I will have to ignore some of the text. Here is the sample text file: SIZE: 4 ROWS, 4 COLUMNS SCORE: 0 0 ----...
9
by: Matrixinline | last post by:
Hi All, Here is the problem char* memblock; std::ifstream file(sFileName, ios::in|ios::binary); if (file.is_open()) { size = file.tellg();
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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.