cprogramming

This is a discussion on cprogramming within the C Programming forums, part of the General Programming Boards category; hello everyone.... sorry, i have a question ? is it possible to declare a variable in types of string ? ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    1

    Lightbulb cprogramming

    hello everyone....
    sorry, i have a question ?
    is it possible to declare a variable in types of string ? if it is then , how??
    thank you!

  2. #2
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    974
    char something[] = "hello!"
    Last edited by Epy; 11-22-2009 at 11:04 AM. Reason: brainfart

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    46
    or
    char *s = "hui";

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    2,053
    Quote Originally Posted by r00t View Post
    or
    char *s = "hui";
    No don't do that. That's only possible for backwards compatibility. Instead do this:

    Code:
    const char *s="can't change me";
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  5. #5
    1337
    Join Date
    Jul 2008
    Posts
    135
    Try this:
    Code:
    char string[4];
    strcpy(string, "This is King Arthur");
    Maybe you will learn something.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about Cprogramming
    By abachler in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 04-10-2008, 09:34 AM
  2. Wikipedia CProgramming Entry?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 07-27-2005, 09:15 PM
  3. #cprogramming
    By Dual-Catfish in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 05-04-2002, 09:37 PM
  4. David's CProgramming Theorem
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 08-14-2001, 12:29 AM

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