4
Contributors
3
Replies
4
Views
13 Years
Discussion Span
Last Post by alc6379
1

rather than

printf("Greetings!\n");

You could use:

const char* greeting = "Greetings!\n";

printf( greeting );

1

How do I make a greeting a named constant rather than a literal constant?

I'm not sure if I completely understand what you are asking.

#include <stdio.h>
 
 int main( void )
 {
    const char named_constant[] = "string literal initializer";
    puts("literal constant"); /* (1) */
    puts(named_constant); /* (2) */
    return 0;
 }
 
 /* my output
 literal constant
 string literal initializer
 */

Are you asking how to do (2) instead of (1)?

1

How do I make a greeting a named constant rather than a literal constant?

cford,

Welcome to TechTalkForums. In the future, please name your thread something meaningful. "HEELLLPPPP!!!! Due Tomorrow 9-14-04" doesn't tell us anything about what you need. "Making a named constant", or something similar would have been more appropriate.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.