Thread: strcat problem..

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    strcat problem..

    here it is...

    char words[100][50];
    char c;
    c = getchar();

    strcat (words[0],c);

    the error says "c" is incompatable, how do i fix this???

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    8

    i figured it out

    I figured it its ok
    "c" had to be an array

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >"c" had to be an array
    It need not be an array, it just has to be a nul terminated sequence of characters. Which means that a string literal or pointer to string literal is perfectly valid:
    Code:
    strcat ( words[0], "Test" );
    or
    Code:
    char *p = "Test";
    
    strcat ( words[0], p );
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. STRCAT problem
    By Frusciante in forum C Programming
    Replies: 9
    Last Post: 07-04-2007, 06:15 AM
  2. Problem with strcat
    By firyace in forum C Programming
    Replies: 9
    Last Post: 05-15-2007, 02:31 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Problem with strcat() function
    By sureshkumarct in forum C Programming
    Replies: 6
    Last Post: 01-03-2007, 08:05 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM