www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/04/12:12:07

From: fredex AT fcshome DOT stoneham DOT ma DOT us
Message-Id: <199606041116.HAA03721@fcshome.stoneham.ma.us>
Subject: Re: Beginners srand error
To: halibut AT kuhub DOT cc DOT ukans DOT edu
Date: Tue, 4 Jun 1996 07:16:27 -0400 (EDT)
Cc: djgpp AT delorie DOT com
In-Reply-To: <1996Jun3.144827.120718@kuhub.cc.ukans.edu> from "halibut@kuhub.cc.ukans.edu" at Jun 3, 96 02:48:27 pm

Thinking furiously, halibut AT kuhub DOT cc DOT ukans DOT edu wrote:
> 
> 
> This gives me a parse error before int:
> 
> void main()
> {
>    srand(time(NULL));
>    int num;
> }
> 
> Anyone know why?

Sure. Because this is C, not C++. In C declarations must be placed
at the top of a block, not just anywhere at random. Try changing it
to look like:

void main()
{
   int num;
   srand(time(NULL));
}

> 


-- 
-------------------------------------------------------------------------------
 .----    Fred Smith    /                        Office: fred AT computrition DOT com 
( /__  ,__.   __   __ /  __   : /                                 508-663-2524 
 /    /  /   /__) /  /  /__) .+'           Home: fredex AT fcshome DOT stoneham DOT ma DOT us 
/    /  (__ (___ (__(_ (___ / :__                                 617-438-5471 
-------------------------------- Jude 1:24,25 ---------------------------------

- Raw text -


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