Hey, I'm new here.
I am in a C programming course in my college. Its an online course so sometimes I can't get the help I need. I don't recommend taking programming as an online course. One really does need a live instructor to understand such important concepts. But I had no choice except an online course.
Anyway, I have an assignment on macros, and its due in a couple of hours. Since I'm in an online course my book is my only instructor, and the book doesn't have ANY examples using macros. It just has lines of code explaining in bits and pieces how to define macros and etc.
My book is C How to Program 5th edition and I program in Visual C++ 2005 express.
I need an example of a macro. My assignment asks me to write a program that uses a macro to sum the values in an array.
From the book I understand that a macro is very similar to a function. But my problem is that, since there are no examples of macros in my book I'm not putting things in the correct places, and getting major errors.
Here is an example macro I tried. It failed horribly. Maybe if you can help me fix this example I will understand enough to do the assignment myself. The following example has nothing to do with my assignment, its just a test to see if I'm doing macros correctly.
Please help me fix that ^^^Code:#include <stdio.h> # define Rect( x, y) ( ( x) * (y ) ) int main( void ) { int rectArea, x, y; rectArea= Rect( x + 4, y + 7) ; printf( "%d ", rectArea ); }