Conditions of c language compiler

#include<stdio.h>
#include<iostream>
#define CORRECT "myfirst"
int main() { char str[10]; int func(char* str1, char* str2); printf ( " output your favorite: \ the n- " ); scanf("%s", str); // If not defined CORRECT macro name is defined in the following #ifndef CORRECT #define CORRECT "Test" #endif // CORRECT IF (FUNC (STR, CORRECT) == 0 ) { printf ( " thank you \ the n- " ); } else { printf ( " sorry \ the n- " ); } system("pause"); return 0; } int func(char* str1, char* str2) { return strcmp(str1, str2); }

Determine whether the presence of the macro, if not further defined.

Here I encountered a problem, I suppose when defining the #define CORRECT "my first" there were spaces, then no matter how I input, always get (func (str, CORRECT) = -. 1 do not know why You should be allowed to have spaces in the string?

The second way:

#include<stdio.h>
#include<iostream>
#define ROUND 1
#define PI 3.14

int main() {
    int a,b;
    double c;
    a = 2;
    B = . 3 ;
 // if ROUND is 1, then the operation of the next statement 
#if ROUND 
    C = (A + B) * the PI * 2 ;
    the printf ( " % .2f \ n- " , C);
 // otherwise run the following statement 
#else 
    C = A + B;
 #endif 
    System ( " PAUSE " );
     return  0 ;
}

Use conditional compilation to compile source code can allow only a summary satisfy the conditions of the block, the target program generates shorter, thereby reducing memory overhead and improve the efficiency of the program.

Guess you like

Origin www.cnblogs.com/xiximayou/p/12128965.html