please Guide me

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iaslam
    New Member
    • Jul 2007
    • 5

    please Guide me

    #include<conio. h>
    #include<stdio. h>
    #include<string .h>
    int main()
    {
    char A[40],B[40];
    char ch;
    int size,i,j;
    puts("plese enter the string to be reversed");
    gets(A);
    puts(A);
    ch='\0';
    size=strchr(A,c h)-A;
    printf("%d",siz e);
    j=0;

    for(i=size;i<0; i--)
    {

    B[j]=A[i];
    j++;

    }

    puts(B);
    getch();
    i am trying ti reverse the string A and trying to store it in the string B but i am unable to be that is there any logical eror or some other error because no syntax error is there and i just wat to reverse the string A and want to stor it in the B using this for loop
    regards
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by iaslam
    #include<conio. h>
    #include<stdio. h>
    #include<string .h>
    int main()
    {
    char A[40],B[40];
    char ch;
    int size,i,j;
    puts("plese enter the string to be reversed");
    gets(A);
    puts(A);
    ch='\0';
    size=strchr(A,c h)-A;
    printf("%d",siz e);
    j=0;

    for(i=size;i<0; i--)
    {

    B[j]=A[i];
    j++;

    }

    puts(B);
    getch();
    i am trying ti reverse the string A and trying to store it in the string B but i am unable to be that is there any logical eror or some other error because no syntax error is there and i just wat to reverse the string A and want to stor it in the B using this for loop
    regards
    Hi,
    Problem is with the for loop u have used it shuld be
    for(i=size;i<0; i--) ///previously i<0
    What u can do is get the string length and initialize the size variable instead of strchr

    Thanks
    Raghuram.

    Comment

    • iaslam
      New Member
      • Jul 2007
      • 5

      #3
      i have again check it but still the same problem persists

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        Originally posted by iaslam
        i have again check it but still the same problem persists
        CHek this one
        [code=cpp]
        #include<conio. h>
        #include<stdio. h>
        #include<string .h>
        int main()
        {
        char A[40],B[40];
        char ch;
        int size,i,j;
        puts("plese enter the string to be reversed");
        gets(A);
        puts(A);
        ch='\0';
        //size=strchr(A,c h)-A;
        size=strlen(A);
        printf("%d",siz e);
        j=0;

        for(i=size;i>0; i--)
        {

        B[j]=A[i];
        j++;

        }

        [/code]

        Raghuram

        Comment

        • iaslam
          New Member
          • Jul 2007
          • 5

          #5
          thanks dear
          regards

          Comment

          Working...