Learnem Educational
May 18, 2012, 12:58:49 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How will the preprocessor EXPAND the code?  (Read 1919 times)
Anonymous
Guest
« on: August 16, 2002, 12:38:51 AM »

[code:jrs19fyv]
#include<stdio.h>

#define USEFLOAT 0

int main(void)
{
int N;

#if USEFLOAT
   float X;
#else
   ;double X;
#endif
   printf("%lf", &X);
   return 0;
}
[/code:jrs19fyv]
This is what I have so far but when i complie it I get a runtime error, can anyone please help me solve this answer. :?:
« Last Edit: January 01, 1970, 12:00:00 AM by Anonymous » Logged
Mr. Cool
Newbie
*
Posts: 11


View Profile
« Reply #1 on: August 16, 2002, 10:58:34 PM »

my compiles an error:
[quote:2ea242x0]C:\Program Files\Microsoft Visual Studio\MyProjects\test16b\t16b.cpp(Cool : error C2601: 'N' : local function definitions are illegal
C:\Program Files\Microsoft Visual Studio\MyProjects\test16b\t16b.cpp(Cool : error C2063: 'N' : not a function

C:\Program Files\Microsoft Visual Studio\MyProjects\test16b\t16b.cpp(15) : warning C4508: 'main' : function should return a value; 'void' return type assumed[/quote]

I think this means you can't perform anything since N is not declared anywhere in the body after initialization. You need to add N somewhere in order to get this to complie and run,sir. :)
« Last Edit: January 01, 1970, 12:00:00 AM by Mr. Cool » Logged
Anonymous
Guest
« Reply #2 on: September 14, 2002, 06:43:54 AM »

This is the correct version

#include <stdio.h>

#define USEFLOAT 0

int main(void)
{
int N;

#if USEFLOAT
   float X;
#else
   double X;
#endif
   printf("%lf", &X);
   return 0;
}


However your compiler will still warn about not using the variable N. What was wrong was the:

#else
   ;double X;

The semikolon should not be there...easy fix..=)
« Last Edit: January 01, 1970, 12:00:00 AM by Anonymous » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!