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

how to fprintf value if i got value in file?

10
my problem is i have 1 coloum of data and i wan to print other data at d next row. how?

for example
data1 data2
happy 5463
sad 67233

i alrdy hv data1 in a .txt, so how i print d data2 inside it?
Aug 28 '07 #1
2 1120
Banfa
9,065 Expert Mod 8TB
You will need to rewite the entire file. The is no such thing as inserting data into a file, all you can do is read all the data following the point that you want to insert new data, the writie your new data and then re-write the old data after the new data.

In your case it would be easier to parse the current file into memory and then overwrite it with the data you require. Alternitively read the current file and write to a temporary file with the data you require. Once you have got to the end of the file close both files, delete the old file and rename the temporary file to the old files name.
Aug 28 '07 #2
isaac86
10
btm is my programme. how i fprintf both digit n data inside a .txt?

{FILE * pFile;
pFile = fopen ("words.txt","r");

while (feof(pFile) == 0){

fgets(data, 20, pFile);
if (data[0] == '#') continue;

wLength = strlen( data);
if(wLength >= 7 && wLength <=10){
for(i=0; i< wLength ;i++ )
{digitConverter(data[i]);
printf("%d",digit);
}printf("\t%s",data);
}}

fclose(pFile);
}
Aug 28 '07 #3

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

Similar topics

2
by: Arti Potnis | last post by:
Hi, I have an application with a function "myfunction" that opens a file and writes to it using fprintf. This application runs on a unix (sun solaris 5.8) system. I connect to this application...
5
by: google | last post by:
first, a little background... i have a C program which preprocesses some data, and then outputs the results into a text file. that text file, in turn, is used as input to a FORTRAN...
6
by: hpy_awad | last post by:
I am writing stings ((*cust).name),((*cust).address)to a file using fgets but rabish is being wrote to that file ? Look to my source please and help me finding the reason why this rabish is being...
8
by: Smegly | last post by:
Hi, I'm confused about a situation i have .. fprintf works in one function, but not in the other . . This is my part of my code for the two functions .. void customer(FILE *fin, FILE...
17
by: G Patel | last post by:
E. Robert Tisdale wrote: > > int main(int argc, char* argv) { > quad_t m = {0, 1, 2, 3}; > int r; > fprintf(stdout, "m = ("); > for (size_t...
3
by: Jim Hunter | last post by:
From what I've read, the only indication fprintf gives of an error is a negative return value. I have a series of writes to a file using fprintf, and, while I need to know if a failure has...
11
by: nertos | last post by:
Why doesn't this fragment work? FILE *file; fopen(argv, "r+"); fprintf(file, "\b"); THX nertos
4
by: baumann | last post by:
hi all, i want to use the fprintf to make log. if defined LOG_TO_FILE, it is easy to use fprintf to write the log file. if not defined LOG_TO_FILE, i want to simply write to error std...
16
by: Prayag Narula | last post by:
Hi, I want to redefine fprintf for debugging purposes. That is I want that all the output that is going to the stdout should be logged in a file. I tried something like #define fprintf...
11
by: David Mathog | last post by:
In the beginning (Kernighan & Ritchie 1978) there was fprintf, and unix write, but no fwrite. That is, no portable C method for writing binary data, only system calls which were OS specific. At...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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,...

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.