- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- printf on itanium2
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2006 03:41 AM
02-03-2006 03:41 AM
on itanium2 this printf:
printf("NOME <%s> <%s> <%s> <%s>\n", argv[0], ((argc == 4) ? argv[1], argv[2], argv[3] : "def1", "def2", "def3"));
produce memory fault
Can help me?
thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2006 04:20 AM
02-03-2006 04:20 AM
SolutionTry something like this:
int main(int argc, char *argv[])
{
int i = -1;
int j = -2;
i,j = (1,2,3);
(void) printf("i = %d j = %d\n",i,j);
return(i);
}
Without testing this, if C works like i think it does, the output should be:
i = -1 j = 3
In your case, only 1 of the 3 pointers gets a value, the remaining arguments are whatever is on the stack (garbage).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 10:44 PM
02-05-2006 10:44 PM
Re: printf on itanium2
bye
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 11:06 PM
02-05-2006 11:06 PM
Re: printf on itanium2
#include
#include
int main(void)
{
int i = 0;
int j = 1;
int k = 2;
int l = 3;
printf("%d %d %d %d\n",
((i == 0) ? k, j, l, i : l, k, i, j));
return (EXIT_SUCCESS);
}
I compiled this one a rp2470 under 11i with the ANSI C HP compiler and it compiled okay, but the resultant output was '1 2097088492 134217759 3'. About what I would expect.
The same code, when compiled under gcc witht he -Wall flag on returns, on compile:
$ gcc -Wall one.c -o one
one.c: In function `main':
one.c:12: warning: left-hand operand of comma expression has no effect
one.c:12: warning: left-hand operand of comma expression has no effect
one.c:12: warning: left-hand operand of comma expression has no effect
one.c:12: warning: left-hand operand of comma expression has no effect
one.c:12: warning: left-hand operand of comma expression has no effect
one.c:12: warning: left-hand operand of comma expression has no effect
one.c:12: warning: too few arguments for format
Actually, a few less errors than I expected, but.....
Wanda, I think you have been extremely lucky if the code you posted actually returned the expected results when compiled with a C compiler. I would recommend that all of the constructs like the one you posted be revised, personnally I would use something on the order of:
printf("NOME <%s> ", argv[0]);
if (argc == 4)
printf("<%s> <%s> <%s>\n", argv[1], argv[2], argv[3]);
else
printf("
But then, the above is personnal coding style, of which arguments can lead to long threads in which nothing much is actually said or accomplished. It is also untested, and written off the top oif my head, so I might jhave made typo's in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2006 11:12 PM
02-05-2006 11:12 PM
Re: printf on itanium2
Hmmm, I would have called that being 'UNlucky'.
It is so much easier to be told your code is broken when it is first written, and not much later when there is a sea filled with red herrings to disguise the problem.
fwiw,
Hein.