Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C - #define

Name: Anonymous 2011-02-15 17:37

Completely beginner question, so please keep answers as simple as possible:
In C programming, what is the purpose of using the #define directive (eg #define PI 3.14), when you can just declare a variable and initialize it to the same value?

Name: Anonymous 2011-02-15 18:22

>>3 he's a troll

you can do complex things like template
#define RADTODEG(x) ((x) * 57.29578)

or include guard


#ifndef FILE_NAME_H
#define FILE_NAME_H

/* code */

#endif // #ifndef FILE_NAME_H

Name: Anonymous 2011-02-15 18:26

>>4

include guard has been deprecated, use #pragma once

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List