Thread: Defines, Macros and Header files

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    31

    Defines, Macros and Header files

    Modify program by saving the function, the define and the macro you wrote in a header file. Run the program using the same or similar main function.

    Code:
    
    
    Code:
    #include<stdio.h>
    #include<conio.h>
    #define name   "Alex Willimson"
    #define address "40 tuxedo court"
    #define student "324-787-647"
    #define prggrade "78.82"
    #define prgmark "B+"
    void fun (void);
    main()
    {
    	fun();
    	getch();
    }
    
    
    void fun(void)
    {
    	printf("NAME: %s",name);
    	printf("\n\nADDRESS: %s", address);
    	printf("\n\nSTUDENTNUMBER: %s" , student);
    	printf("\n\nPRG155 Grade %%: %s",prggrade);
    	printf("\n\nPRGMARK: %s",prgmark);
    	return(0);
    	getchar();
    }

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    505
    C programs can have more than one source file. It's normal to have a fairly short main(), then the rest of the program in functions, organised in files according to a logical arrangement of type.
    That's what the exercise is trying to get you to understand.
    I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
    Visit my website for lots of associated C programming resources.
    https://github.com/MalcolmMcLean


  3. #3
    Registered User
    Join Date
    Mar 2013
    Posts
    31
    Can you please help me to add the source file?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Mar 2013
    Posts
    31
    Thank you very much Mr.Salem.

    You help me a lot. Thank you Boss!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Defines and Header file
    By hnparmar in forum C Programming
    Replies: 8
    Last Post: 03-25-2013, 01:47 PM
  2. namepaces and header file defines
    By manav in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2007, 10:09 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. Replies: 4
    Last Post: 12-14-2005, 02:21 PM
  5. include library header in header files
    By Raison in forum C++ Programming
    Replies: 6
    Last Post: 09-27-2004, 02:50 AM