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

divide first column from a txt file

hy guys,
I am a beginner in c and from 3 days I have a big question...
I have a file containing the folowing data:
5971 -44 976 -23
5981 -53 980 -23
5991 -50 978 -21
6001 -56 975 -21
6011 -58 971 -21
6021 -52 981 -24
6031 -49 974 -22
6041 -50 981 -31
6051 -47 978 -37
6061 -42 978 -38
6071 -37 977 -42
I need to divide the first column by 600 to convert in to seconds and write it out into a new file first column divided and the second, 3'th, 4'th leave it like is it now....
can anyone help me?
please???
Thanx a lot
Apr 9 '10 #1
3 1612
whodgson
542 512MB
I know this sounds like buck passing but why don`t you rewrite the file with an extra field populated by col_1/600........then refer to this field direct
Apr 11 '10 #2
jkmyoung
2,057 Expert 2GB
Also, how did you want the column formatted? Did you want only whole seconds, or decimals to the tenth?
Apr 12 '10 #3
#include <stdio.h>
#include <conio.h>
void main(void)
{
FILE *pointer_fisier;
FILE *pointer_fisier2;
int t,x,y,z,c;

pointer_fisier2=fopen("datepout.txt","w");
if ((pointer_fisier = fopen("peter6.txt", "r")) == NULL)
printf("Error opening peter6.txt for input\n");
do{
fscanf(pointer_fisier, "%d %d %d %d", &t, &x, &y, &z);
c=t/600;
fprintf(pointer_fisier2, "\n t = %4d \t x = %4d \t y = %4d \t z = %4d",c,x,y,z);
}while(!feof(pointer_fisier));
fclose(pointer_fisier);
fclose(pointer_fisier2);
printf("\n End!!!");getch();
}



this is it... I must take a book and remember some c but it is working now...
Apr 14 '10 #4

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

Similar topics

0
by: Gary Carson | last post by:
Can anyone tell why the query below would throw a divide-by-zero error? The only reason I can see for the error happening would be if SUM() came out to be zero, but this never happens with the...
12
by: Paul T. RONG | last post by:
Is it possible to divide a tall subform with 80 records to two subforms each with 40 records? Dear All, What I have: Tables: tblProduct, tblOrder, tblOrderDetail
5
by: per.nordlow | last post by:
Hey there! I want to multiply/divide (shift) a float with variable containing a power-of-two value: 2, 4, 8, 16, .... Is there such a function in the C standard library or the glibc library...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
3
by: Joriveek | last post by:
When I specify a formula between Computed Column Specification, I have two zero values, getting Divide by Zero error, any idea how can I avoid this? I still want SQL Server to display Zero if it is...
3
by: aldonnelley | last post by:
Hi all. Just having a weird problem with tkinter. I'm trying to make a gui that shows results from an image search, with a "forward" and "back" button so the user can compare results from...
2
by: abhasinha | last post by:
hi There is two columns in table name and emp...name column contains the names of some people and emp is a flag--'y' or'n'.we are suppossed to divide the name column into two columns emp_name and...
1
by: Justin.Velazquez | last post by:
Hello everyone, I'm not really new to programming but my bitwise skills definately need work. I came across a problem I've been trying to figure out for fun. I'm trying to write a routine...
27
by: jty0734 | last post by:
i wanna large divide. input is 1~1024 bit integer. first, i think using sub is solution. so i made two array. and sub divisor to dividend. but this situation happen.
1
by: prasadgopathi | last post by:
hi friends, i have one table is normal column is bit id isnormal 1 0 2 0 3 0 4 1
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?
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...

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.