prashanthi.07
BAN USER#include<stdio.h>
#include<string.h>
char* StrReverse(char* str)
{
char *temp, *ptr;
int len, i;
temp=str;
for(len=0; *temp !='\0';temp++, len++);
ptr=malloc(sizeof(char)*(len+1));
for(i=len-1; i>=0; i--)
*(ptr+len-i-1)=*(str+i);
*(ptr+len)='\0';
return ptr;
}
int main()
{
char string;
printf("enter the string to be reversed \n");
scanf("%s",string);
strReverse(string);
printf("the reversed string is %s",string);
}
Array is a collection of similar type of data items and each item is called element of an array.
each element will share the same variable name but have different index.
eg:
int age[50];
float sal[20];
pointer is a variable that stores the memory address.Its called as pointer because it points to a particular address in memory by storing that address.
int *ptr;
int age=30;
ptr=&age;
#include<stdio.h>
- prashanthi.07 September 17, 2011#include<string.h>
char* StrReverse(char* str)
{
char *temp, *ptr;
int len, i;
temp=str;
for(len=0; *temp !='\0';temp++, len++);
ptr=malloc(sizeof(char)*(len+1));
for(i=len-1; i>=0; i--)
*(ptr+len-i-1)=*(str+i);
*(ptr+len)='\0';
return ptr;
}
int main()
{
char string;
printf("enter the string to be reversed \n");
scanf("%s",string);
rev = strReverse(string);
printf("the reversed string is %s",rev);
}