The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Python: popen problems sendai Shell Programming and Scripting 2 06-11-2007 06:05 PM
help needed with sort. pipe and popen() the_learner UNIX for Dummies Questions & Answers 7 05-21-2007 04:24 PM
using popen with background process matrixmadhan High Level Programming 7 08-22-2006 03:02 AM
popen and tar, please HELP! stef83 High Level Programming 4 05-25-2005 07:41 AM
query in popen collins High Level Programming 1 11-07-2004 06:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-05-2003
Registered User
 

Join Date: Oct 2001
Posts: 8
question about popen();

Hi
The following is my program to test popen()
routine. The purpose is to print some contents
of the corrent directory.
But in fact, the output is only one character
'a', which I believe is the first char of the file
"a.out".
So, can anybody tell me what is wrong about
this program?
Thanks.

#include <stdio.h>
main()
{
FILE* pipe;
int i;
char ch;

pipe=popen("ls","r");
for (i=0;i<=15;i++);
{
ch= fgetc(pipe);
printf("%c\n",ch);
}
}
Reply With Quote
Forum Sponsor
  #2  
Old 05-05-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
Your "for" loop isn't connected to your "for" statement. Drop that last semicolon on the same as your "for" statement.
Reply With Quote
  #3  
Old 05-05-2003
Registered User
 

Join Date: Oct 2001
Posts: 8
thanks

thank you
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0