473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.

Aug 20 '07 #1
13 2148
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
Aug 20 '07 #2
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
Aug 20 '07 #3
Umesh <fr****************@gmail.comwrites:
#include <stdio.h>
#include <conio.h>
#include<string.h>

int main(void)
{
char str1[]="abcd",str2[]="efgh";
int i;
for(i=0;i<strlen(str1);i++)
printf("%c\n",str1[i]);
for(i=0;i<strlen(str2);i++)
{
gotoxy(2,i+1);
printf("%c\n",str2[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:

http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php

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_Keith) ks***@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"
Aug 20 '07 #4
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.
Aug 21 '07 #5
Umesh <fr****************@gmail.comwrites:
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_Keith) ks***@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"
Aug 21 '07 #6
In article <5i*************@mid.individual.net>,
Ian Collins <ia******@hotmail.comwrote:
>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!

Aug 21 '07 #7
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrote:
>Umesh <fr****************@gmail.comwrites:
>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.

Aug 21 '07 #8
"Kenny McCormack" <ga*****@xmission.xmission.comschrieb im Newsbeitrag
news:fa**********@news.xmission.com...
In article <5i*************@mid.individual.net>,
Ian Collins <ia******@hotmail.comwrote:
>>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?
Aug 21 '07 #9
"Joachim Schmitz" <no*********@schmitz-digital.dewrote:
"Kenny McCormack" <ga*****@xmission.xmission.comschrieb im Newsbeitrag
news:fa**********@news.xmission.com...
In article <5i*************@mid.individual.net>,
Ian Collins <ia******@hotmail.comwrote:
>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
Aug 21 '07 #10
Keith Thompson said:
Umesh <fr****************@gmail.comwrites:
<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
Aug 21 '07 #11
>>>>"RH" == Richard Heathfield <rj*@see.sig.invalidwrites:

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
cw*****@chromatico.net
Aug 21 '07 #12
Charlton Wilbur <cw*****@chromatico.netwrites:
>>>>>"RH" == Richard Heathfield <rj*@see.sig.invalidwrites:
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_Keith) ks***@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"
Aug 21 '07 #13
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

Aug 21 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Jeroen van vliet | last post by:
I have a program that when clicked i want to print 2000 papers, with the names adress etc of customers. So it have to print every record. How to manage it? Jeroen
4
by: Pekka Niiranen | last post by:
Hi, I have a multiuser script, that I would like to convert to Python. The users open simultaneous telnet -sessions from win2000 to an unix machine and possibly edit unicode textfiles. Currently...
4
by: Paul Rubin | last post by:
How about adding a string interpolation method and a some print methods to strings. 'hello world'.print() => same as "print 'hello world'". With optional fd arg, print to file object 'hello...
2
by: Jack Russell | last post by:
Gee vb.net makes me feel dumb! My understanding is that I set up and do all of my printing in the printdocument printpage and handler using various graphics methods such as drawstring. Is...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
5
by: Patrick De Ridder | last post by:
How can I turn what I want to print 90 degrees using the logic below? Please tell me the code with which to make the modification. Many thanks, Patrick. using System.ComponentModel; using...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
2
by: utab | last post by:
Dear all, On a formatted printing operation that I am trying to accomplish for doubles, I have a question. I would like to print a double, d, and its square, d*d, but I would like to make the...
2
by: David | last post by:
Hi list. I've never used unicode in a Python script before, but I need to now. I'm not sure where to start. I'm hoping that a kind soul can help me out here. My current (almost non-existant)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.