char * s = "Hello";
while(*s)
{
// note: you should be checking if p is going to be valid, but thats upto you.
// on the first iteration its not going to work... a simple 'if' statement or for() loop would fix this.
char p = *s-1, c = *s; // p is prev, c is current char
*s++;
}

03-31-2007

dwks

If the OP doesn't know about strings, I highly doubt they know about pointers. :)

BUT, what if I haven't studied pointer, array and functions too. I've just finished studying loop and basic of C like getting characters or lines from key board, and counting them.

Isn't there any way with much knowledge?

04-02-2007

quzah

You've managed to get three people to do your homework for you, or very close to it. Let's see what you actually have done.

Quzah.

04-02-2007

javani

Quote:

Originally Posted by quzah

You've managed to get three people to do your homework for you, or very close to it. Let's see what you actually have done.

Quzah.

sorry, u r interpreting wrongly. I am not a computer student nor it's a homework. I am just following book and learning C from that. And, what I am asking is WHAT I don't know, or don't know how to start?

I've done word counting program, vowel counting. But it's out of my reach, i think. I don't know how to do two character comparision at a time. Hope cleared!

04-03-2007

quzah

Use one variable to track the current character you've just read, and one to hold the one you read right before that. If they're not the same, move this one into the "last time" holder, and read a new one into the "just read" holder. Repeat until done.