English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

the output has to show like this::

Buffer Contents:this is a nice example
Buffer Contents:for the program isn't it

Contents of the string array:
This
is
a
nice
example
for
the
program
is't
it
Press any key to continue.....

2006-12-07 04:34:45 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

uhh i dunno what u mean by Buffer contents, i'm just gonna assume they're both char arrays, let's take them as string1[] & string2[] (lengths depending on the actual contents, yo!)

wot u need here is a loop that prints the string letter by letter, with a small addition of going to a new line every time it encounters a space.
I'm gonna assume you've included stdio.h, conio.h and declared an integer i. Of course, the 2 strings should also be declared as well as defined.
well, here goes: (u better copy-paste in notepad to read it properly)

for( i=0 ; string1[i]!='\0' ; i++)
{
/* the middle condition teminates the loop on string completion*/
printf("%c",string1[i]);
if(string1[i] == ' ')
printf('\n'); /*print newline if u find a space*/
} /* end of for loop
printf('\n');

for( i=0 ; string2[i]!='\0' ; i++)
{
printf("%c",string2[i]);
if(string2[i] == ' ')
printf("\n");
}
printf("\nPress any key to continue....");
getch();
}

warning: if there are two spaces in a row, this program's gonna newline twice.

note: you can replace the printf() command by cout<< , with appropriate syntax. I'm more used to coding in C now...

2006-12-07 04:54:37 · answer #1 · answered by answerQuest 2 · 0 0

|> EVAL *testc:s 100 |
| *testc:s 100 = |
| "This is the first line. This is the second line. This is the" |
| "third line." |
|> EVAL *testc:f 100 |
| *testc:f 100 = |
| This is the first line. |
| This is the second line. |
| This is the third line.

2006-12-07 12:38:52 · answer #2 · answered by god knows and sees else Yahoo 6 · 0 0

If no method is specified....simply use cout<< statements..

2006-12-07 12:38:17 · answer #3 · answered by Anonymous · 0 1

i dont know if u get it then tell me pls

2006-12-07 12:36:21 · answer #4 · answered by Spicy Ketchup 4 · 0 1

fedest.com, questions and answers