Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-08-2004, 05:26 AM   #1
LQ Newbie
Registered: Nov 2003
Posts: 7

Rep: Reputation: 0
fprintf is not working in rpc server pgm

for some program i want to print records to a file in a remote machine using rpc.when i tried to run this program ,the fprintf() statement failed. code is some thing like this,
fp = fopen("somefile","w");
why it is so?
Old 01-08-2004, 09:33 PM   #2
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Use gdb on the core it dumps. My guess is that fopen is returning NULL for some reason (no write access to the file? Directory doesn't exist?)

Also, make sure that str1 and str2 are NULL-terminated.

I'd recommend changing your code to something like this:

if((fp = fopen("somefile", "w")) == NULL)
fprintf(stderr, "Couldn't open file for writing: %s\n", strerror());

fprintf(fp, "%s%s", str1, str2);

You'll have to #include <errno.h> for strerror(). It would at least tell you the reason it can't open the file (if that really is the problem) then.

Last edited by itsme86; 01-08-2004 at 09:41 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
NFS server: RPC: Program not registered burbank Linux - Networking 11 09-15-2011 03:04 PM
NFS RPC: Port mapper failure - RPC: Unable to receive KEJP Linux - Networking 6 12-18-2006 03:14 AM
RPC not working berrance Linux - Software 7 10-10-2005 01:25 PM
rpc.lockd & rpc.statd twantrd Linux - General 1 05-21-2005 10:24 AM
Unmounting NFS filesystems: Cannot MOUNTPROG RPC: RPC ErnstVikenstein Linux - General 4 05-31-2003 01:10 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration