delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/12/07:42:12

Sender: crough45 AT amc DOT de
Message-Id: <97Jun12.133709gmt+0100.16695@internet01.amc.de>
Date: Thu, 12 Jun 1997 12:41:07 +0100
From: Chris Croughton <crough45 AT amc DOT de>
Mime-Version: 1.0
To: kdor AT geocities DOT com
Cc: djgpp AT delorie DOT com
Subject: Re: what am I doing wrong

Kristian Dorland wrote:

> I have just installed djgpp for the first time, and I can4t create c-
> programs that4s working properly. Every time I run a program compiled
> with djgpp, there is somthing wrong with the contents of the integers
> and the floatings. An example:
>
> main()
> 
>   {
>   int one == 1234;
>   printf("%d",one);
>   }

Well, of course the compiler will get confused because you've called 
the variable 'one' and then expected it to hold 1234.  Try renaming 
the variable to 'onetwothreefour' so it knows what the value is.

Or as a last resort you could read a C manual and find out the 
difference between '=' and '=='.  But I doubt that's your problem 
because you say the compiler doesn't give an error.  It does if I try
to compile your program as stated.  If, in fact, you had:

main()
{
  int one;
  one == 1234;  // should be one = 1234;
  printf(%d", one);
}

then that would be the answer.

Or if you declared it as a float and then printed it using "%d".

Chris

- Raw text -


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