[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: char *test[position]



On Fri, 11 Jun 1999, Felix Kollmann wrote:

> I try to get a char of a char * :
> 
> 	unsigned int position= 0;
> 	char *test;
> 	printf ("%s", test[position]);
> 
> But the programm prints the complete string down to [position] .

Use %c as your formatting code instead of %s...%s will print until it hits
a null char, I believe.

i.e.
char *test = "asdf qwerty";
printf("%c\n", test[3]);

should print the character f and a newline char.

-j
--
Joel R. Stanley                   *  jstanley@up.edu       
http://rainier.up.edu/~jstanley   *  #include <std_disclaimer.h>