main()
{
char str[30];
int i ,n=0;
printf("enter stirng");
while(( str[n]= getche() ) !='\r')  
n++;
str[n]='\0';    
for(i=0;i<n;i++)
putchar(str[i]);
}

this is a simple program. enter string as input and same string become output.
nothing is wrong in this program. this program is in my book.
my question is what is the meaning of

while(( str[n]= getche() ) !='\r')

line i could not understood that. plz someone explain this line.

str[n]= getche() will get a character from the keyboard and echos it to the screen. It then puts an integer into str on position(starting at zero) n. A check is done to see if that integer, returned by getche() is not equal with '\r'. If succes n is incremented and the while continues, else the while ends.
You also should test that n, never gets greater than 29.
You should write this code part like this:

while(( str[n]= getche() ) !='\r') 
{
  n++;
}
str[n]='\0';

Good Example for String program thank you @ddanbe

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.