How do I word this lol...

This is a discussion on How do I word this lol... within the C Programming forums, part of the General Programming Boards category; I am working on a program that is modular and alot of it's function is very procedural and repetitive. I'm ...

  1. #1
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765

    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.

    Code:
    #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
    	getch();
    	printf(message, "Different Line B");
    	getch();
    	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
    Posts
    14,826
    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." );

    Quzah.
    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, 06:49 PM
  3. Passing structures to a function
    By earth_angel in forum C++ Programming
    Replies: 5
    Last Post: 07-13-2005, 07:13 AM
  4. Word Count
    By simple in forum C Programming
    Replies: 12
    Last Post: 10-04-2002, 11:47 PM
  5. Help with a troublesome C++ program
    By Kristina in forum C++ Programming
    Replies: 4
    Last Post: 05-18-2002, 02:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21