Easy Question

This is a discussion on Easy Question within the C++ Programming forums, part of the General Programming Boards category; I have been searching the boards but could not find an answer to my question. I am trying to store ...

  1. #1
    Unregistered
    Guest

    Easy Question

    I have been searching the boards but could not find an answer to my question. I am trying to store a word. I have tried many different things but I think the closest was this:

    Code:
    char x[256];
    
    switch (input)
       {
       case 1: answer = a + b;
               char x = 'sum'; // wanting to store the word "sum"
               break;
       case 2: answer = a - b;
               char x = 'difference'; // wanting to store the word "difference"
               break;
       case 3: answer = a * b;
               char x = 'unknown'; // wanting to store the word "unknown"
               break;
       case 4: answer = a / b;
               char x = 'quotient'; // wanting to store the word "quotient"
               break;
        }
    I think I am on the right track, just my syntax is wrong.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    strcpy(x, "sum");
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282
    or don't declare it in the beginning...

    say

    char x[] = "sum";

    char x[] = "difference";

    etc

    wherever you need it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. easy Vector contructor question
    By noodle24 in forum C++ Programming
    Replies: 5
    Last Post: 04-21-2006, 08:43 PM
  2. Another Embarassingly Easy Question
    By almo89 in forum C Programming
    Replies: 2
    Last Post: 02-11-2006, 04:59 PM
  3. This is hopefully an extremely easy question...
    By rachaelvictoria in forum C Programming
    Replies: 2
    Last Post: 11-07-2005, 01:36 AM
  4. 4 easy question
    By Zeratulsdomain in forum C++ Programming
    Replies: 2
    Last Post: 10-15-2005, 11:43 PM
  5. Quick Easy Question
    By St0rmTroop3er in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 02-24-2004, 01:08 AM

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