Re: taking a "word" as input
- From: Nick Keighley <nick_keighley_nospam@xxxxxxxxxxx>
- Date: Wed, 30 Apr 2008 06:43:20 -0700 (PDT)
On 30 Apr, 23:02, arnuld <NoS...@xxxxxxxxxx> wrote:
.> On Tue, 29 Apr 2008 02:47:18 -0700,Nick Keighleywrote:
are all your words the same size?
It depends on the user, what he likes to input at run-time.
in other words, no.
santosh has pointed out some of the design drivers for this.
So decide do you want a fixed size (limits word size and wastes space)
or a variable size (harder to program).
If you use the array of pointers you'll have to get the memory
for each word from somewhere (eg. malloc())
Note Well
yes. I came up with this code and as you can see it does not do what I
want. I want to take every word into the input but it only takes 1st for
obvious reasons. I am not able to think of the way to take all the words
of the input:
1. after you read a word you need to skip to the next word.
eg. read until you get a letter
2. you need somewhere to store the words. Either a 2D array or
use malloc().
#include <stdio.h>
#include <ctype.h>
enum MAXSIZE { MAXWORD = 100 };
char *getword( char *, int );
int main(void) {
char buffer[MAXWORD];
this only holds one word
char buffer[MAXNUMWORDS][MAXWORD];
OR char* buffer [MAXWORD]
getword( buffer, MAXWORD );
pass the appropriate argument
<snip>
--
Nick keighley
.
- References:
- taking a "word" as input
- From: arnuld
- Re: taking a "word" as input
- From: Nick Keighley
- Re: taking a "word" as input
- From: arnuld
- taking a "word" as input
- Prev by Date: Re: Is cast operator unary or binary? How many operands?
- Next by Date: Re: struct versioning
- Previous by thread: Re: taking a "word" as input
- Next by thread: Re: taking a "word" as input
- Index(es):
Relevant Pages
|