943,492 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2325
  • C RSS
Sep 13th, 2004
1

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

Expand Post »
How do I make a greeting a named constant rather than a literal constant?
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
cford is offline Offline
1 posts
since Sep 2004
Sep 13th, 2004
1

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

rather than

printf("Greetings!\n");

You could use:

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

printf( greeting );
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 2004
Sep 13th, 2004
1

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

Quote originally posted by cford ...
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.
  1. #include <stdio.h>
  2.  
  3. int main( void )
  4. {
  5. const char named_constant[] = "string literal initializer";
  6. puts("literal constant"); /* (1) */
  7. puts(named_constant); /* (2) */
  8. return 0;
  9. }
  10.  
  11. /* my output
  12.  literal constant
  13.  string literal initializer
  14.  */
Are you asking how to do (2) instead of (1)?
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Sep 13th, 2004
1

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

Quote originally posted by cford ...
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.
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: using crt debug in visual studio.net
Next Thread in C Forum Timeline: 'times' coding problem?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC