06-19-2009
segmentation fault in fwrite function
Hi,
my code is written in proC and it is in UNIX(AIX).I have written a small code for writing data into a binary file,but while writing my program is giving core dump.
Here Is my code----
fpWriteFile = fopen(WriteFileName,"wb+");
CHAR *recvgen;
recvgen = (char *)malloc(sizeof(char)*NSE_MAX_PACKET_RECV_SIZE);
fwrite (recvgen,NSE_MAX_PACKET_RECV_SIZE,1,fpWriteFile );
10 More Discussions You Might Find Interesting
1. Programming
Code : function sSaveTFFile
.......................
iRetCode = link (caCurrentFilename, caBackupFilename);
if (iRetCode == -1)
{
ERR_MSG2(LOG_ALERT, "Can't move %s to %s", caCurrentFilename, caBackupFilename);
return(FAILURE);
}
iRetCode = unlink... (6 Replies)
Discussion started by: fermisoft
6 Replies
2. Programming
I am working on the application in which I have to fetch values from the database and paste in url and send it to portal.
table=get_result("SELECT serialno,cas,Mode,FLC,TLC,location,CompName,CompCode,FG,FC,DispNo,TruckNo,LWbill,RRGPN,INVNO,DCN,RQTY,DQTY,SQTY,DDATE,RDATE,SDATE,TTIME FROM... (1 Reply)
Discussion started by: er.rohan88
1 Replies
3. Programming
I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek:
#include </usr/include/mysql++/mysql++.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string.h>
using namespace std;
int outputToImport(const char*... (1 Reply)
Discussion started by: sepoto
1 Replies
4. Programming
This code is causing a segmentation fault and I can't figure out why. I'm new to UNIX and I need to learn how to avoid this segmentation fault thing. Thank you so much. Thanks also for the great answers to my last post.:):b:
int main()
{
mysqlpp::Connection conn(false);
if... (3 Replies)
Discussion started by: sepoto
3 Replies
5. Programming
I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this :
i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies
6. Programming
The fwrite function call is not returning error, when the file it writes to is removed, please advise on how to find if the file already opened and being written by a program is removed manually or by some other process.
please see the code below,
#include<stdio.h>
#include<stdlib.h>
... (3 Replies)
Discussion started by: Kesavan
3 Replies
7. Shell Programming and Scripting
I am getting Segmentation fault at below function call in my script:
get_x() {
sqlplus -s / <<end | grep KEEP | sed 's/KEEP//;s///g'
select 'KEEP' ,table_name from all_synonyms where upper(synonym_name)= '$1';
exit
end
x=$(get_x $1)
echo " SQL OUTPUT IS :: $x"
}
I am getting output of... (1 Reply)
Discussion started by: IB_88
1 Replies
8. UNIX for Dummies Questions & Answers
I have some matlab code that sends the serial port elements of an array using matlab's fwrite function, e.g.:
fwrite(s, , 'uchar');
What would be a unix shell equivalent? E.g., after successfully accessing the port using instructions here:
Simple terminal serial port program for Linux/MacOSX... (3 Replies)
Discussion started by: darwin_886
3 Replies
9. Programming
I am passing a char* to the function "reverse" and when I execute it with gdb I get:
Program received signal SIGSEGV, Segmentation fault.
0x000000000040083b in reverse (s=0x400b2b "hello") at pointersExample.c:72
72 *q = *p;
Attached is the source code.
I do not understand why... (9 Replies)
Discussion started by: jose_spain
9 Replies
10. Programming
Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1...
I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one.
Below are two very condensed snippets of which I have added the results inside the each code section.
IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies
fopen(3UCB) SunOS/BSD Compatibility Library Functions fopen(3UCB)
NAME
fopen, freopen - open a stream
SYNOPSIS
/usr/ucb/cc[ flag ... ] file ...
#include <stdio.h>
FILE *fopen( file, mode);
const char *file, *mode;
FILE *freopen(file, mode, iop);
const char *file, *mode;
register FILE *iop;
DESCRIPTION
The fopen() function opens the file specified by file and associates a stream with it. If the open succeeds, fopen() returns a pointer to
be used to identify the stream in subsequent operations. The file argument points to a character string that contains the name of the file
to be opened. The mode argument is a character string having one of the following values:
r open for reading
w truncate or create for writing
a append: open for writing at end of file, or create for writing
r+ open for update (reading and writing)
w+ truncate or create for update
a+ append; open or create for update at EOF
The freopen() function opens the file specified by file and associates the stream pointed to by iop with it. The mode argument is used just
as in fopen(). The original stream is closed, regardless of whether the open ultimately succeeds. If the open succeeds, freopen() returns
the original value of iop.
The freopen() function is typically used to attach the preopened streams associated withstdin, stdout, and stderr to other files.
When a file is opened for update, both input and output can be performed on the resulting stream. Output cannot be directly followed by
input without an intervening fseek(3C) or rewind(3C). Input cannot be directly followed by output without an intervening fseek(3C) or
rewind(3C). An input operation that encounters EOF will fail.
RETURN VALUES
The fopen() and freopen() functions return a NULL pointer on failure.
USAGE
The fopen() and freopen() functions have transitional interfaces for 64-bit file offsets. See lf64(5).
SEE ALSO
open(2), fclose(3C), fopen(3C), freopen(3C), fseek(3C), malloc(3C), rewind(3C), lf64(5)
NOTES
Use of these functions should be restricted to applications written on BSD platforms. Use of these functions with any of the system
libraries or in multithreaded applications is unsupported.
To support the same number of open files as the system, fopen() must allocate additional memory for data structures using malloc(3C) after
64 files have been opened. This confuses some programs that use their own memory allocators.
The fopen() and freopen() functions differ from the standard I/O functions fopen(3C) and freopen(3C). The standard I/O functions distin-
guish binary from text files with an additional use of 'b' as part of the mode, enabling portability of fopen(3C) and freopen(3C) beyond
SunOS 4.x systems.
SunOS 5.10 22 Jan 1993 fopen(3UCB)