int = char ??????

This is a discussion on int = char ?????? within the C++ Programming forums, part of the General Programming Boards category; char szSTRING1[]="test"; int length=szSTRING1; thats my current code...but my compiler (dev c++) says initilazation to 'int' from 'char*' lacks a ...

  1. #1
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070

    int = char ??????

    char szSTRING1[]="test";
    int length=szSTRING1;

    thats my current code...but my compiler (dev c++) says

    initilazation to 'int' from 'char*' lacks a cast

    what does that mean...or how do i make a int variable equal the length of a char variable???

    thanks ahead of time
    -psychopath

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    Code:
    #include <cstring>
    
    // other stuff
    
    int main()
    {
    // other stuff
    
      length = strlen(szSTRING1);
    
    //other stuff
    }

    Dave

  3. #3
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    k thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 04:45 AM
  2. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 09:36 PM
  3. Replies: 14
    Last Post: 06-28-2006, 02:58 AM
  4. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 PM

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