![]() |
| | #1 |
| Registered User Join Date: Jun 2003
Posts: 60
| display 10 consecutive lines........... "Display the user's name input from the keyboard in 10 consecutive lines, using the variable once..." I don't get it,.. I have an idea that I'll type the name " John Lennon " and then it'll print the whole name down in 10 lines... please, give me your ideas... hints or perhaps a simple source code... thanks |
| imbecile in C is offline | |
| | #2 |
| Registered User Join Date: Jul 2002
Posts: 913
| im not sure about the "variable once" part. can you do this? Code: #define MAX_NAME 25
#include <stdio.h>
int main() {
int x = 1;
char name[MAX_NAME + 1];
printf("What is your name?\n");
fgets(name, MAX_NAME, stdin);
printf("\nHeres your name 10 more times\n");
while(x < 11) {
printf("%i) %s", x, name);
++x;
}
return 0;
}
|
| mart_man00 is offline | |
| | #3 | |
| End Of Line Join Date: Apr 2002
Posts: 6,240
| Re: display 10 consecutive lines........... Quote:
Code: char once[BUFSIZ];
if (fgets(once, sizeof once, stdin))
{
/* Now loop to print 10 times */
}
__________________ When all else fails, read the instructions. If you're posting code, use code tags: [code] /* insert code here */ [/code] | |
| Hammer is offline | |
| | #4 |
| Registered User Join Date: Jun 2003
Posts: 60
| Oi !! thanks !! I've taken full note of your ideas and hints... i'll compile it on our lab,.. and check everything !! Thanks a lot Dudes !! |
| imbecile in C is offline | |
| | #5 |
| End Of Line Join Date: Apr 2002
Posts: 6,240
| Just in case you didn't get it, mine was a sarcastic response
__________________ When all else fails, read the instructions. If you're posting code, use code tags: [code] /* insert code here */ [/code] |
| Hammer is offline | |
| | #6 | |
| Registered User Join Date: Jan 2003
Posts: 78
| Quote:
| |
| Rog is offline | |
| | #7 |
| +++ OK NO CARRIER Join Date: Oct 2001
Posts: 10,615
| And even more amusing, we use the variable once once. Code: char once[BUFSIZ], *p = once;
fgets( p, BUFSIZ, stdin );
printf("%s%s%s%s%s%s%s%s%s%s"
,p,p,p,p,p,p,p,p,p,p);
Quzah.
__________________ Hundreds of thousands of dipshits can't be wrong. Are you up for the suck? Last edited by quzah; 07-09-2003 at 07:40 PM. |
| quzah is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem I Can't solve... | ferniture | C Programming | 3 | 07-15-2008 02:51 AM |
| Array help | Oklaskull | C Programming | 19 | 03-11-2008 04:15 PM |
| Continuous refresh | Bill83 | Windows Programming | 11 | 01-24-2006 12:50 PM |
| Heaps... | Nutshell | C Programming | 14 | 04-23-2002 08:54 AM |
| Formatting Output | Unregistered | C Programming | 6 | 03-26-2002 01:33 AM |