delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/30/05:56:05

Date: Mon, 30 Mar 1998 12:36:25 +0200 (MET DST)
From: Federico Spinazzi <federico AT SysPr03 DOT disat DOT unimi DOT it>
To: Nicolas Blais <eletech AT netrover DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Why won't this work?
In-Reply-To: <351E8C26.2608F112@netrover.com>
Message-ID: <Pine.LNX.3.93.980330123304.23359A-100000@SysPr03.disat.unimi.it>
MIME-Version: 1.0

Wow, it could be the first time I CAN reply to a question (I'm only a
beginner...)

On Sun, 29 Mar 1998, Nicolas Blais wrote:

> Hi,
> Check the code below, can't figure out why this doesn't work, I mean,
> should it exit when I enter exit?  Also, when I type spaces into my
> string, it creates as many ":" as I inputed spaces.  Can anyone fix
> this?
> 
> getcommand(void)
> {
> char *p;
> char *com;
>  for (p = ":"; *p;p++)
>  put_char(*p, 10);
>  scanf("%s",com);
>  if (strcmp(com, "exit") == 0)        exit(0);
>  getcommand();
>  return 1;
> }
> 

If you would allocate memory for com, you'll be able to put something in
it with scanf.

You can declare an array for com:
char com[22222222222222];
(is it big enough ?)

Well, I hope to be right...

federico

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019