Sunday, January 1, 2017

Reversing a word entered from keyboard in C without using 'stack'

Hello friends !                                                Happy New Year 2017 !

To  coders and code lovers all over  the world.........

I hope you will find this piece of code interesting. Please respond with alternative ideas/modifications to improve the code.
//Input a word at console from keyboard and get its reverse (without using STACK !)
#include<stdio.h>
int main()
{
    char c[]="                                            "; // Put enough white spaces (more than expected word size)
    printf("type a word :");
    scanf("%s",&c);
    for(int i=(sizeof(c)-1);i>=0;i--)
    {
        printf("%c",c[i]);
    }
return 0;
}

No comments:

Post a Comment

How can I run a C++ program directly from Windows?

How-can-I-run-a-C-program-directly-from-Windows