delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/04/04/17:30:07

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: function question
Date: Sun, 04 Apr 2004 17:27:37 -0400
Lines: 43
Message-ID: <c4puki$2kov8r$1@ID-227552.news.uni-berlin.de>
References: <106vune1fu63e7a AT corp DOT supernews DOT com>
NNTP-Posting-Host: user-2iveb5f.dialup.mindspring.com (165.247.44.175)
Mime-Version: 1.0
X-Trace: news.uni-berlin.de 1081114067 88898843 I 165.247.44.175 ([227552])
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113
X-Accept-Language: en-us, en, de, fr, ru, zh, ja
In-Reply-To: <106vune1fu63e7a@corp.supernews.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Bill Cunningham wrote:

>     I don't know if it would be better to post this here or comp.lang.c but
> I'll post it here since it's djgpp specific. 

If it were djgpp-specific, it is obvious that it goes to 
comp.os.msdos.djgpp, not to comp.lang.c, where compiler-specific 
questions are off-topic.

However, your question has nothing to do with djgpp, but with basic, 
elementary C.

>I'm working on some open source
> programming and seem to have run up against a wall. Can anyone give me any
> pointers(no pun intended) on this.
> 
> int ma (int np[])
>         {puts("This is number of prices? -> ");
>          fflush(stdout);
>          puts(int *(np));}
> 
> What this function is supossed to do is accept input of a number of prices
> an investor wants to include in a simple moving average. Hince the ma. The
> int * cast is the last thing to my knowledge to try. I know workable C. I'm
> not really experienced with the fancy ins and outs. As the funcion
> continues, it should tally a number of prices and calculate a ma. Then I'll
> include it into a static library where it can be linked with a file
> containing main().

'int *' is not a cast; it's a syntax error.  With a cast, the line
          puts((int *)np);
makes no sense, and the cast is superfluous as well.
Your argument list suggests that np is an array, with the "code" 
suggesting np[0] holds the value you want.  This is probably not true.

int ma(int *np)
{
    printf("This is number of prices? -> %d\n", *np);
    return *np; /* ? */
}


C is really easy if you bother to learn it before coding.

- Raw text -


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