linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Assignment  make pointers
@ 2004-12-13 10:04 r_zaca
  2004-12-13 10:10 ` Jan-Benedict Glaw
  0 siblings, 1 reply; 11+ messages in thread
From: r_zaca @ 2004-12-13 10:04 UTC (permalink / raw)
  To: linux-c-programming

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 1063 bytes --]

  If you take a look in "man 3 basename", you'll see that basename function 
just returns a pointer to a char. In the case above you need to "cast" the 
pointer returned to be of type int. 
  Like: prog_ptr = (int *) basename (argv[0]); 
  I hope it will help you. 
  Good luck. 


Hello, 

New to the list and to C. Read O'Reilly's Practical C Programming and 
another C book and am now trying to evolve beyond helloworld.c. When I 
compile the snippet below, gcc-3.4.2 on Fedora Core 3 spits out: 
test2.c:11: warning: assignment makes pointer from integer without a 
cast 
test2.c:12: warning: passing arg 1 of `usage' from incompatible pointer 
type 

I just can't figure out why it does that and how to fix it since my 
pointer/casting/C knowledge is definitely lacking. The snippet does work 
ok. Anyone care to enlighten me? 

#include <stdio.h> 

void usage(int *prog_ptr) 
{ 
	fprintf(stdout,"progname is: %s\n",*prog_ptr); 
} 
	 
int main(int argc, char *argv[]) 
{ 
	int *prog_ptr; 
	prog_ptr = basename (argv[0]); 
	usage(&prog_ptr); 
	return(0); 
} 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-12-30 13:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-13 10:04 Assignment make pointers r_zaca
2004-12-13 10:10 ` Jan-Benedict Glaw
2004-12-13 14:51   ` Eric Bambach
2004-12-13 14:58     ` Eric Bambach
2004-12-13 15:01       ` C Newbie Darren Sessions
2004-12-13 15:50         ` Jan-Benedict Glaw
2004-12-13 16:03         ` Eric Bambach
2004-12-29  2:13         ` Defunct Processes Darren Sessions
2004-12-29 10:16           ` Jan-Benedict Glaw
2004-12-30 13:14             ` Daniel Souza
2004-12-13 15:47     ` Assignment make pointers Jan-Benedict Glaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).