Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C Program doesn't output anything on UNIX??

Status
Not open for further replies.

NeedMiscHelp

Programmer
Joined
Dec 12, 2002
Messages
7
Location
US
I've tried a test program with a printf("Hello"); statement in main and it doesn't output anything?? I've tried it on FreeBSD 4.6.2 and 4.7 and Solaris (I think 4). Any ideas??
 
Why don't you post the source so it can be examined for incorrect syntax?
 
Sure, I know it's not wrong though, since I compiled with no errors, and I compiled and run on Windows:

#include<stdio.h>

int main()
{
printf(&quot;Hello&quot;);
return 0;
}

also tried C++, same result- nothing:

#include<iostream.h>

int main()
{
cout<<&quot;Hello&quot;;
return 0;
}
 
Ahh found the error...when I type &quot;test&quot; at the command-line, it's trying to run &quot;/usr/bin&quot; test. FIX: ./test
 
Possibly the compiler you're using? Just throwing that out. The code is fine (kind of hard to screw up a hello), and I compiled and ran it on my AIX system without error.

I would have to go with the compiler. You said it compiled and ran on Windows, but if the compiler is a Windows compiler then using it on Unix probably would give you strange behavior because of the architecture differences on the platforms. Did it compile on Unix? If so, I would still say a compiler issue since if it is a Windows compiler.
 
Try to add a newline character at the end of the string:

printf (&quot;Hello\n&quot;);



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top