Operating System - HP-UX
1752502 Members
5200 Online
108788 Solutions
New Discussion юеВ

Re: C printf code not appearing

 
SOLVED
Go to solution
Curtis Deese
Frequent Advisor

C printf code not appearing

I have a short test C program that uses several printf commands. When I run the program, there is never any output. Why am I not getting any output from the printf statements and how do I resolve the problem?

The program is below:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include


main()
{
char user_id[30];
char password[30];
char server_name[30] ;

strcpy(user_id, "XXX");
strcpy(password, "XXX");
strcpy(server_name, "XXX");

printf("user_id %s\n", user_id);
printf("password %s\n", password);
printf("server_name %s\n", server_name);
Return 0;
}

8 REPLIES 8
Dennis Handly
Acclaimed Contributor

Re: C printf code not appearing

If your output is buffered, you may have to call fflush(3) to get the output to come out immediately.

Other than the typo for "Return" and the lack of int for main, the program seems fine.

What HP-UX version are you using? What architecture? What compiler version?
Still Integrity 11.31?
Curtis Deese
Frequent Advisor

Re: C printf code not appearing

I am using HP-UX 11.31 Integrity. I do not know the compiler version, but I am using cc. The file is a ProC file (test.pc)

Here is the Makefile I am using:

include /u01/app/oracle/product/11.2.0/db_1/precomp/lib/env_precomp.mk

CFLAGS=-D_USE_BIG_FDS -Ae -DHPUX -DORAIA64 -DHPUX_IA64 +DD64 -DSS_64B \
-IT_SERVER -DHPPA64 -DSLS8NATIVE -DSLU8NATIVE +DD64 -DSS_64BIT_SERVER

all: test

test: test.o
$(CC) -o test test.o -L $(LIBHOME) $(PROLDLIBS)

test.o: test.c
$(CC) $(CFLAGS) $(PRECOMPPUBLIC) -c test.c

test.c: test.pc
$(PROC) $(PROCPLSFLAGS) iname=test.pc

clean:
rm -f test.o testlog.o test.c

cleanall: clean
rm -f test
Steven Schweda
Honored Contributor

Re: C printf code not appearing

> The program is below:
> [...]

That's "test.pc"?

> [...] The file is a ProC file (test.pc)

"The file" is the same as "The program"?

Some of us lack Oracle, making it tough to
see what's happening here. Care to exhibit
"test.c"? (Have _you_ looked at it?)

> [...] I do not know the compiler version,
> but I am using cc. [...]

uname -a
cc -V

> [...] $(LIBHOME) $(PROLDLIBS)

> [...] $(PRECOMPPUBLIC) [...]

Can't see those macros from here, either.
Hein van den Heuvel
Honored Contributor

Re: C printf code not appearing

KISS.

Reduce, try, expand, retry.
You might be building/running the wrong thing.

Try this.... just feed it into cc and execute a.out
---
#include
#include
main()
{
char user_id[30];

strcpy(user_id, "XXX");

printf("user_id %s\n", user_id);

}

That works right?
Now feed it to pro*c, then cc. ... still works?
Add some switches... still works?
Use the make file.
Check with ls -ltr test.*
Every thing in 'order' and build as expected?

Good luck!

btw... what is 'Return' ? typo?
Dennis Handly
Acclaimed Contributor

Re: C printf code not appearing

As Steven said, what's in test.c? Does ProC somehow remove your printf calls?
Tom Henning
Trusted Contributor
Solution

Re: C printf code not appearing

I will assume that the program compiles and you called the executable 'test'. You are trying to execute the program by typing 'test' from a bourne or ksh shell. If you execute:

type test

it will respond with (at least on my system it does) "test is a shell builtin.". So your program never gets executed. Try running it with: ./test or call it something else.

What is it that possesses otherwise sane individuals to change something just because it has not been changed in a while?
Curtis Deese
Frequent Advisor

Re: C printf code not appearing

./test worked. I don't know what I was thinking naming the program 'test'. Thanks for your help.
Steven Schweda
Honored Contributor

Re: C printf code not appearing

> ./test worked. [...]

One of the advantages to showing actual
commands with their actual output is that
other people can see your actual mistakes.
If all you say is that you ran your program,
then many people will assume that you
actually did what you said that you did.
This may force you to wait for someone to
guess what you did (wrong), which is often
not the fastest path to the answer.