On 2006-05-18, vim <> wrote:
> hi guys
>
You are already annoying me with your lack of capitals.
> this is my code
One sec, here's a cleaned up version:
#include <stdio.h>
int main(void)
{
char *p[]={"hello" ,"world" ,"Nice","show"};
char **p1;
p1 = p; /* As per your most recent post */
/* You should have posted context */
/* Actual code here */
return 0;
}
> I want to print the string "helwornicsho" by using ptr increment or
> decrement.
What is "ptr"? I don't see it in your code.
> How can I do that.
> I tried to print charachter by charachter .
Easier to set the fourth character of each string to '\0' and then
printf ("%s", p[i]), no?
> But for that increment ptr pointing to each charachter .
> I used (**p1)++.But it is giving segmentation fault.
**p1 points to the letter h, which is part of a string literal. You
don't need to increment that, and if you could you'd end up with 'i'
instead of the next letter.
Use *p1++ to jump to the next word, and p1++ to jump to the next
letter. The parentheses are unnecessary.
> Plz tell the error.
>
What does "plz" mean? That isn't in your code either.
--
Andrew Poelstra <
http://www.wpsoftware.net/blog >