Hey guys i have the following code just wondering how i can print a particular character in the pointer array. For eample 'w' or the second last 'd'?
Code:char *worddude[] = {"dude!"}; printf("the value of word is %s",*worddude);
Hey guys i have the following code just wondering how i can print a particular character in the pointer array. For eample 'w' or the second last 'd'?
Code:char *worddude[] = {"dude!"}; printf("the value of word is %s",*worddude);
Well, you're not going to be able to print 'w' because it's just part of your variable name. Unless you open the executable file and look up the symbol table then you're limited to printing the characters in the string "dude!". You can print an individual character from it by printing worddude[0][whatever_char].
If you understand what you're doing, you're not learning anything.
Code:printf("%c",*worddude[n]); //n is the place of the chararcter u want to print..considering the first to be at place n=0
Last edited by PING; 08-24-2005 at 09:14 AM.
Code:>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.
Ah good old Ping. Close, but never correct...
Lose the *.Originally Posted by PING
Quzah.
Hope is the first step on the road to disappointment.
Actually, you need the *, but OOO is incorrect. *worddude[n] will print the first character of the nth string which is not what you want. The correct way is (*worddude)[n] which will print the nth character of the first string.Originally Posted by quzah
If you understand what you're doing, you're not learning anything.
D'oh. I wasn't seeing the * in the origional declaration for some reason.
Quzah.
Hope is the first step on the road to disappointment.
Same here..thats y i had to edit my post..D'oh. I wasn't seeing the * in the origional declaration for some reason.
yup, my bad, forgot to put those brackets..neways, m off to sleep now.(*worddude)[n]
Code:>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.