Thread: How do I word this lol...

  1. #1
    Join Date
    Sep 2001

    How do I word this lol...

    I am working on a program that is modular and alot of it's function is very procedural and repetitive. I'm sure one of you know a simple solution to this, yet it's hard to word.

    #include <stdio.h>
    #include <conio.h>
    int main()
    	#define message ( clrscr(), "\nLine1\nLine2\n%s\nLine4\n\nPress any key...")
            // This needs to go somewhere "local"
    	printf(message, "Different Line A");
            // Sub files would insert the difference
    	printf(message, "Different Line B");
    	return 0;
    Is there a way I could use this in a modular program?
    Say I have a main source file. I then have a header file which is included into that source file. There are other header files included into the main header file. There's only 3 links. The sub headers are linked into the main header, in which the main header is linked into the main program file.

    The sub headers are going to be repeating the same information with little change. With the above example of code I'm wondering how you would do that in a modular program. Would there be a way to "define" the message somewhere where every sub file could call it, then add it's change to it?
    The world is waiting. I must leave you now.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Why on earth did you make your define that way? Eeew.

    #deifine MESSAGE(x) clrscr( );printf( "\nLine1\nLine2\n%s\nLine4\n\nPress any key..." x )

    Call this:

    MESSAGE( "Hello." );

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hangman game and strcmp
    By crazygopedder in forum C Programming
    Replies: 12
    Last Post: 11-23-2008, 06:13 PM
  2. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  3. Passing structures to a function
    By earth_angel in forum C++ Programming
    Replies: 5
    Last Post: 07-13-2005, 06:13 AM
  4. Word Count
    By simple in forum C Programming
    Replies: 12
    Last Post: 10-04-2002, 10:47 PM
  5. Help with a troublesome C++ program
    By Kristina in forum C++ Programming
    Replies: 4
    Last Post: 05-18-2002, 01:28 PM