strcat problem..

This is a discussion on strcat problem.. within the C Programming forums, part of the General Programming Boards category; here it is... char words[100][50]; char c; c = getchar(); strcat (words[0],c); the error says "c" is incompatable, how do ...

  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,796
    >"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, 07:15 AM
  2. Problem with strcat
    By firyace in forum C Programming
    Replies: 9
    Last Post: 05-15-2007, 03:31 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07: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

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