Hello,
I am new to this site, found reference through google.com.
I am attaching a sample code.
The variable “file_nm is pointed to proper file.

I am suppose to write a program, which will…

1. Open a file.

2. Search for string “APPLY DATE:
e.g. APPLY DATE:

3. If the string is found then place the date next to that statement
i.e. the statement should look like

APPLY DATE: 2004-07-28:21:32:16

4. But somehow my code is not working as per expectations, it is writing
a junk character along with the date
i.e. the output looks like

Apply Date:ÿ2004-07-28:21:32:16
My Code: Please ferfer to the attached file

Questions:
1] What is that junk character stands for?
2] What is wrong with the code?

Thanks in Advance.

Recommended Answers

All 3 Replies

hello,
I saw u r code and i am expecting one answer if right(u think) consider other wise leave it.

After reading the set of strings it will move to end of the file. As u stored only the APPLY DATE and u have given to read 256 possible characters file pointer moves to end of file. so now u r writing after tht , so that is nothing but a special symbol to indicate the end of file

that's i am expecting.

ok

bye

Hi,

Thanks for the reply. appreciated!!

My file is very large in size. I am writing only the part of it out here.

This is a report output file and below is the header of the file
after the header, the file contains the output from a particular table.
I need to update only the header after the report gets generated.

Header:

Configuration Name: \ANDES DEFAULT
Configuration Revision: 5
Software Release: Z08.00
Apply Date:ÿ2004-07-28:21:32:16
Site Id: 035409
System Name: \ANDES
Logical Target Name: DEFAULT
: : : :
: : : :
: : : :

And here the Apply Date is getting junk character when I use fputs.

Thanks in Advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.