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

rewrite to file

i want that my prog will rewrite (update) to exsist file if it was found a string im searching for inside this file, so i did this:
fptr=fopen("data.txt","r+"); // i also tried "a+"
fscanf(fptr,"%s\n",tmp_name); //tmp_name is a vector.
if (strcmp(myname,tmp_name)==0)
{
fprintf("%d %d %f %d",won,lost,avg,best);
}
fclose(fptr);

my file is a txt file and looks like this:

name1
1 2 3.3 5
name2
1 2 3.3 5

and i want to chk if name1==myname then change the 1 2 3.3 5 to 7 8 9.9 5
did what i was doing is illigel ? coz i cant get it to work...(the fprintf is doing nothing..), or maybe some1 know other way to do this ?
thanks !
Dec 7 '06 #1
1 2929
i want that my prog will rewrite (update) to exsist file if it was found a string im searching for inside this file, so i did this:
fptr=fopen("data.txt","r+"); // i also tried "a+"
fscanf(fptr,"%s\n",tmp_name); //tmp_name is a vector.
if (strcmp(myname,tmp_name)==0)
{
fprintf("%d %d %f %d",won,lost,avg,best);
}
fclose(fptr);

my file is a txt file and looks like this:

name1
1 2 3.3 5
name2
1 2 3.3 5

and i want to chk if name1==myname then change the 1 2 3.3 5 to 7 8 9.9 5
did what i was doing is illigel ? coz i cant get it to work...(the fprintf is doing nothing..), or maybe some1 know other way to do this ?
thanks !

for updating a file in c u should use the fseek function in your c program,
fseek(fptr,location,0);
try this and send me reply at
ertarunkumar@yahoo.co.in
Dec 19 '06 #2

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

Similar topics

5
by: T | last post by:
Hi group, I'm trying to create a temporary replacement scheme for a particular url that gets generated all over an existing app. It would be very difficult to find every spot where the url gets...
1
by: ltt19 | last post by:
Hi I have a very big .txt file, about 17MB, and my application need to read it and make changes at any time I can put it in a variable and my program writes the file again oly in the end of the...
14
by: Stan Canepa | last post by:
This post is mostly for discussion. Why rewrite in .NET? Just a general discussion not related to any specific details. I was just looking to see what reasons developers are looking to, to help...
5
by: Lupus | last post by:
Hello everybody In apache I used a feature called a "Rewrite rule" inside a .htaccess file to process the URL : i.e. http://www/mypage.html =http://www/page.php?page=mypage Now I'd like to do...
18
chunk1978
by: chunk1978 | last post by:
hi everyone. i just started learning how to dynamically show/hide elements with a checkbox toggle. i would like to know if it's possible to delete/rewrite elements instead of simply show/hide...
1
by: Anees | last post by:
hi i was trying to implement mode rewrite option in a blog site. i used the lines for listing the posts by its topic category as #List by Category RewriteRule ^Topics/(+)$ index.php?cat=$1 ...
4
by: Harsh Trivedi | last post by:
Hi, We have implemented URL rewriting in our site. It all went OK till home page links. When we click on home page category control, where we have implemented rewriting, it works ok, and open...
0
by: jrd | last post by:
Hello, I am very new to PHP. What I need to do is read an XML file (RSS feed) into memory, iterate through the file changing one particular value for each entry, and write a new XML file with a...
3
by: Joe | last post by:
Hello, I currently have a file system where images and assets are stored in a directory like this: http://www.domain.com/assets/media/CLIENT_NAME/uploads/CLIENT_DIR/CLIENT_FILES Which holds...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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.