N
netforce
Hi,
I am a newbie trying to learn c programming language.
I am writing a program to reverse a string and printout the result. The
following isthe program.But I am not getting any output while trying to
print.Somebody help me
#include<stdio.h>
#include<string.h>
main()
{
char str[] ="?lla to tseriaf eht is ohw roriM roriM";
char str2[40];
char *p;
int i;
clrscr();
p=str2;
printf("\n\nthe given string is %s\n\n ",str);
for(i=(strlen(str));i>=0;i--)
{
*p=str;
printf("%c",*p);
p++;
}
*p='\0';
printf("\n\nThe reversed string is%s",str2);
getch();
}
the contents of str2 are not getting printed.
I am using a turbo c++ compiler 3.0.
I am a newbie trying to learn c programming language.
I am writing a program to reverse a string and printout the result. The
following isthe program.But I am not getting any output while trying to
print.Somebody help me
#include<stdio.h>
#include<string.h>
main()
{
char str[] ="?lla to tseriaf eht is ohw roriM roriM";
char str2[40];
char *p;
int i;
clrscr();
p=str2;
printf("\n\nthe given string is %s\n\n ",str);
for(i=(strlen(str));i>=0;i--)
{
*p=str;
printf("%c",*p);
p++;
}
*p='\0';
printf("\n\nThe reversed string is%s",str2);
getch();
}
the contents of str2 are not getting printed.
I am using a turbo c++ compiler 3.0.