954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HEELLLPPPP!!!! Due Tomorrow 9-14-04

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

cford
Newbie Poster
1 post since Sep 2004
Reputation Points: 11
Solved Threads: 0
 

rather than

printf("Greetings!\n");

You could use:

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

printf( greeting );

Chainsaw
Posting Pro in Training
436 posts since Jun 2004
Reputation Points: 36
Solved Threads: 11
 
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)?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 
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.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You