Something wrong with my code, why Junk character appears?

Reply

Join Date: Sep 2004
Posts: 2
Reputation: hiunnati is an unknown quantity at this point 
Solved Threads: 0
hiunnati hiunnati is offline Offline
Newbie Poster

Something wrong with my code, why Junk character appears?

 
0
  #1
Sep 24th, 2004
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.
Attached Files
File Type: txt file_operation_incorrect.txt (362 Bytes, 14 views)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 1
Reputation: prashu522 is an unknown quantity at this point 
Solved Threads: 0
prashu522 prashu522 is offline Offline
Newbie Poster

Re: Something wrong with my code, why Junk character appears?

 
0
  #2
Sep 24th, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 2
Reputation: hiunnati is an unknown quantity at this point 
Solved Threads: 0
hiunnati hiunnati is offline Offline
Newbie Poster

Re: Something wrong with my code, why Junk character appears?

 
0
  #3
Sep 24th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,335
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 236
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Something wrong with my code, why Junk character appears?

 
0
  #4
Sep 24th, 2004
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC