Printing strings columnwise

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Umesh

    Printing strings columnwise

    I was just wondering how to print two strings coulmnwise.

    char string1[]="abcd";
    char string2[]="efgh";

    now i want to print something like this:

    a e
    b f
    c g
    d h

    i was trying to use gotoxy(2,0); but it is not working.

  • pete

    #2
    Re: Printing strings columnwise

    Umesh wrote:
    >
    I was just wondering how to print two strings coulmnwise.
    >
    char string1[]="abcd";
    char string2[]="efgh";
    >
    now i want to print something like this:
    >
    a e
    b f
    c g
    d h
    >
    i was trying to use gotoxy(2,0); but it is not working.
    /* BEGIN new.c */

    #include <stdio.h>

    int main(void)
    {
    char string1[]="abcd";
    char string2[]="efgh";
    size_t index;

    for (index = 0; index != sizeof string1 ; ++index) {
    printf("%c %c\n", string1[index], string2[index]);
    }
    return 0;
    }

    /* END new.c */


    --
    pete

    Comment

    • Umesh

      #3
      Re: Printing strings columnwise

      Thank you. But in my program i need to print the first sequnce first
      and then the second sequnce. I hope u understand my problem.

      After printing the first sequence in the first column I've to print
      the second sequence in the second column.

      pete wrote:
      Umesh wrote:

      I was just wondering how to print two strings coulmnwise.

      char string1[]="abcd";
      char string2[]="efgh";

      now i want to print something like this:

      a e
      b f
      c g
      d h

      i was trying to use gotoxy(2,0); but it is not working.
      >
      /* BEGIN new.c */
      >
      #include <stdio.h>
      >
      int main(void)
      {
      char string1[]="abcd";
      char string2[]="efgh";
      size_t index;
      >
      for (index = 0; index != sizeof string1 ; ++index) {
      printf("%c %c\n", string1[index], string2[index]);
      }
      return 0;
      }
      >
      /* END new.c */
      >
      >
      --
      pete

      Comment

      • Keith Thompson

        #4
        Re: Got it!

        Umesh <fraternitydisp osal@gmail.comw rites:
        #include <stdio.h>
        #include <conio.h>
        #include<string .h>
        >
        int main(void)
        {
        char str1[]="abcd",str2[]="efgh";
        int i;
        for(i=0;i<strle n(str1);i++)
        printf("%c\n",s tr1[i]);
        for(i=0;i<strle n(str2);i++)
        {
        gotoxy(2,i+1);
        printf("%c\n",s tr2[i]);
        } //initial position is given by gotoxy(1,1);
        return 0;
        >
        }
        pete wrote:
        [snip]

        Neither <conio.hnor gotoxy() is part of standard C. If you have
        questions about either of them, you need to post to a newsgroup where
        they're topical, probably a Windows or DOS group.

        Please don't top-post. Read the following to understand what
        top-posting is and why it's discouraged:




        Please don't change the subject header when you post a followup. It
        makes it difficult to follow the discussion. The original subject was
        "Printing strings columnwise"; since you're still discussing that,
        changing the subject header can only cause confusion.

        I recall from your last flurry of postings here that you weren't very
        good at listening to advice. I hope you've improved.

        --
        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
        San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
        "We must do something. This is something. Therefore, we must do this."
        -- Antony Jay and Jonathan Lynn, "Yes Minister"

        Comment

        • Ian Collins

          #5
          Re: Got it!

          Umesh wrote:
          But this doesn't work when i try to put the output in a text file
          >
          Still too rude to post correctly I see..

          --
          Ian Collins.

          Comment

          • Keith Thompson

            #6
            Re: Got it!

            Umesh <fraternitydisp osal@gmail.comw rites:
            But this doesn't work when i try to put the output in a text file
            >
            FILE *fout;
            fout=fopen("c:/output.txt","w" );
            >
            then fprintf etc
            No, of course it doesn't work.
            Hi, Keith i think it's better to work than to waste time giving
            advices. thx
            And if you weren't too rude to post properly, somebody might explain
            why it doesn't work (or at least where you can ask).

            Bye.

            --
            Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
            San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
            "We must do something. This is something. Therefore, we must do this."
            -- Antony Jay and Jonathan Lynn, "Yes Minister"

            Comment

            • Kenny McCormack

              #7
              Re: Got it!

              In article <5ivnmpF3q1akkU 4@mid.individua l.net>,
              Ian Collins <ian-news@hotmail.co mwrote:
              >Umesh wrote:
              >But this doesn't work when i try to put the output in a text file
              >>
              >Still too rude to post correctly I see..
              It's called independence; not kowtowing to "The Man".
              It's what made this country great. Hooray for the Red, White, and Blue!

              Comment

              • Kenny McCormack

                #8
                Re: Got it!

                In article <lnir79mdnp.fsf @nuthaus.mib.or g>,
                Keith Thompson <kst-u@mib.orgwrote:
                >Umesh <fraternitydisp osal@gmail.comw rites:
                >But this doesn't work when i try to put the output in a text file
                >>
                >FILE *fout;
                >fout=fopen(" c:/output.txt","w" );
                >>
                >then fprintf etc
                >
                >No, of course it doesn't work.
                >
                >Hi, Keith i think it's better to work than to waste time giving
                >advices. thx
                >
                >And if you weren't too rude to post properly, somebody might explain
                >why it doesn't work (or at least where you can ask).
                Umesh, you must understand that, living as he does in his parent's
                basement, Keith has nothing better to do than give (screwball) advice
                here on clc.

                Comment

                • Joachim Schmitz

                  #9
                  Re: Got it!

                  "Kenny McCormack" <gazelle@xmissi on.xmission.com schrieb im Newsbeitrag
                  news:faekb4$p7a $1@news.xmissio n.com...
                  In article <5ivnmpF3q1akkU 4@mid.individua l.net>,
                  Ian Collins <ian-news@hotmail.co mwrote:
                  >>Umesh wrote:
                  >>But this doesn't work when i try to put the output in a text file
                  >>>
                  >>Still too rude to post correctly I see..
                  >
                  It's called independence; not kowtowing to "The Man".
                  It's what made this country great. Hooray for the Red, White, and Blue!
                  What country, France, Netherlands, Laos, Kuba?


                  Comment

                  • Richard Bos

                    #10
                    Re: Got it!

                    "Joachim Schmitz" <nospam.jojo@sc hmitz-digital.dewrote :
                    "Kenny McCormack" <gazelle@xmissi on.xmission.com schrieb im Newsbeitrag
                    news:faekb4$p7a $1@news.xmissio n.com...
                    In article <5ivnmpF3q1akkU 4@mid.individua l.net>,
                    Ian Collins <ian-news@hotmail.co mwrote:
                    >Umesh wrote:
                    >But this doesn't work when i try to put the output in a text file
                    >>
                    >Still too rude to post correctly I see..
                    It's called independence; not kowtowing to "The Man".
                    It's what made this country great. Hooray for the Red, White, and Blue!
                    What country, France, Netherlands, Laos, Kuba?
                    Well, since they were our colours first...

                    Richard

                    Comment

                    • Richard Heathfield

                      #11
                      Re: Got it!

                      Keith Thompson said:
                      Umesh <fraternitydisp osal@gmail.comw rites:
                      <snip>
                      >Hi, Keith i think it's better to work than to waste time giving
                      >advices. thx
                      >
                      And if you weren't too rude to post properly, somebody might explain
                      why it doesn't work (or at least where you can ask).
                      Hey, Keith, come on, fair's fair - you keep telling people not to feed
                      the trolls, and it's patently obvious that Umesh is either a troll or
                      far more stupid than is generally considered possible for a human. What
                      are you doing - fattening him up for Christmas?

                      --
                      Richard Heathfield <http://www.cpax.org.uk >
                      Email: -www. +rjh@
                      Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                      "Usenet is a strange place" - dmr 29 July 1999

                      Comment

                      • Charlton Wilbur

                        #12
                        Re: Got it!

                        >>>>"RH" == Richard Heathfield <rjh@see.sig.in validwrites:

                        RHHey, Keith, come on, fair's fair - you keep telling people not
                        RHto feed the trolls, and it's patently obvious that Umesh is
                        RHeither a troll or far more stupid than is generally considered
                        RHpossible for a human. What are you doing - fattening him up
                        RHfor Christmas?

                        Living in perpetual hope, it looks like from here.

                        Can't fault Keith for being an optimist.

                        Charlton


                        --
                        Charlton Wilbur
                        cwilbur@chromat ico.net

                        Comment

                        • Keith Thompson

                          #13
                          Re: Got it!

                          Charlton Wilbur <cwilbur@chroma tico.netwrites:
                          >>>>>"RH" == Richard Heathfield <rjh@see.sig.in validwrites:
                          RHHey, Keith, come on, fair's fair - you keep telling people not
                          RHto feed the trolls, and it's patently obvious that Umesh is
                          RHeither a troll or far more stupid than is generally considered
                          RHpossible for a human. What are you doing - fattening him up
                          RHfor Christmas?
                          >
                          Living in perpetual hope, it looks like from here.
                          >
                          Can't fault Keith for being an optimist.
                          Umesh hadn't posted for a while; I had hoped me might have learned
                          something during his absence, and I thought it couldn't hurt to give
                          him a chance to demonstrate it. Oh, well.

                          --
                          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                          San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
                          "We must do something. This is something. Therefore, we must do this."
                          -- Antony Jay and Jonathan Lynn, "Yes Minister"

                          Comment

                          • CBFalconer

                            #14
                            Re: Got it!

                            Ian Collins wrote:
                            Umesh wrote:
                            >
                            >But this doesn't work when i try to put the output in a text file
                            >
                            Still too rude to post correctly I see..
                            I have him/her/it plonked from way back, and the only annotation is
                            "hopeless".

                            --
                            Chuck F (cbfalconer at maineline dot net)
                            Available for consulting/temporary embedded and systems.
                            <http://cbfalconer.home .att.net>



                            --
                            Posted via a free Usenet account from http://www.teranews.com

                            Comment

                            Working...