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

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2004
Posts: 1
Reputation: cford is an unknown quantity at this point 
Solved Threads: 0
cford cford is offline Offline
Newbie Poster

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

 
1
  #1
Sep 13th, 2004
How do I make a greeting a named constant rather than a literal constant?
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 11
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

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

 
1
  #2
Sep 13th, 2004
rather than

printf("Greetings!\n");

You could use:

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

printf( greeting );
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,442
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 250
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

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

 
1
  #3
Sep 13th, 2004
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)?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

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

 
1
  #4
Sep 13th, 2004
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.
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC