Sponsored Content
Full Discussion: Another set of eyes
Top Forums Programming Another set of eyes Post 302221054 by redoubtable on Sunday 3rd of August 2008 06:27:35 AM
Old 08-03-2008
I found an error on your code, not sure if it is the only one.

Code:
while (fread(&comment_block,sizeof(comment_block),2,fpt) > 0) {

from the manual:

Code:
The function fread() reads nmemb elements of data, each size bytes long, from the stream pointed to by stream, storing them at the location given by ptr.

So what you're doing is reading 2 elements of data from fpt, BOTH with size sizeof(comment_block) thus overflowing your buffer.
What you should be doing is,
Code:
fread(&comment_block, sizeof(comment_block)/2, 2, fpt) > 0)

 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need some help with this script -- extra eyes

I have two issues with this script. 1. I cannot seem to get my counters to count correctly. 2. My function to eject to CAP1 or CAP2 is hung in a loop and doens't exit back to the previous function. I would like to be able to select which cap to eject to . Each cap holds only 40 tapes, so when one... (15 Replies)
Discussion started by: gzs553
15 Replies

2. What is on Your Mind?

use ears to protect eyes before the computer.

If you listen to the files on the computer with ears, your eyes are protected. Microsoft Text-To-Speech(TTS) voice engine has been installed by default on Windows 2000, XP, Vista, you can find what voice engines have been installed on the computer by following Control Panel->Speech->Speech... (0 Replies)
Discussion started by: tgst
0 Replies

3. Shell Programming and Scripting

Broke Perl Script Second pair of eyes NET::FTPSSL

Hi all, Let me first start out by saying I'm a perl newbie and hope somebody can help, for the life of me I can't figure out why my script will not find and download a remote file via FTPSSL. What it's supposed to do is find the latest file named... (4 Replies)
Discussion started by: Styles
4 Replies

4. Shell Programming and Scripting

Would appreciate a quick second set of eyes on a script (regarding doing things in the background)

What I'm trying to do is leave a tcpdump running all the time on a server, and at the end of every day kill it and start a new one. For some reason my boss doesn't want to set this up as a cron job, so I've come up with the following.: #!/bin/bash PCAPFILE=/tmp/mgmt.$(date... (8 Replies)
Discussion started by: DeCoTwc
8 Replies

5. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies
PUTC(3S)																  PUTC(3S)

NAME
putc, putchar, fputc, putw - put character or word on a stream SYNOPSIS
#include <stdio.h> int putc(c, stream) char c; FILE *stream; int putchar(c) int fputc(c, stream) FILE *stream; int putw(w, stream) FILE *stream; DESCRIPTION
Putc appends the character c to the named output stream. It returns the character written. Putchar(c) is defined as putc(c, stdout). Fputc behaves like putc, but is a genuine function rather than a macro. Putw appends word (that is, int) w to the output stream. It returns the word written. Putw neither assumes nor causes special alignment in the file. SEE ALSO
fopen(3S), fclose(3S), getc(3S), puts(3S), printf(3S), fread(3S) DIAGNOSTICS
These functions return the constant EOF upon error. Since this is a good integer, ferror(3S) should be used to detect putw errors. BUGS
Because it is implemented as a macro, putc treats a stream argument with side effects improperly. In particular putc(c, *f++); doesn't work sensibly. Errors can occur long after the call to putc. 7th Edition November 6, 1985 PUTC(3S)
All times are GMT -4. The time now is 12:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy