Results 1 to 5 of 5

Thread: why these errors?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    why these errors?

    this is in my timer...
    PHP Code:
    milli++;
        if(
    milli>=10)  {
            
    milli=0;
            
    secs++;
        }
        if(
    secs>=10)  {
            
    secs=0;
            
    mins++;
        }
        
    char time;
        
    char buffer[6];
        
    strcat(timeitoa(minsbuffer6));
        
    strcat(time":");
        
    strcat(timeitoa(secsbuffer6));
        
    strcat(time":");
        
    strcat(timeitoa(millibuffer6));
        
    SendMessage(ghWnd_clockWM_SETTEXT0, (LPARAM) (LPCTSTRtime); 
    it basically is a stopwatch, but I get all these errors!
    Code:
    error C2664: 'strcat' : cannot convert parameter 1 from 'char' to 'char *'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    C:\Windows\Desktop\C c++\Win32_clock\clock.cpp(108) : error C2664: 'strcat' : cannot convert parameter 1 from 'char' to 'char *'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    C:\Windows\Desktop\C c++\Win32_clock\clock.cpp(109) : error C2664: 'strcat' : cannot convert parameter 1 from 'char' to 'char *'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    C:\Windows\Desktop\C c++\Win32_clock\clock.cpp(110) : error C2664: 'strcat' : cannot convert parameter 1 from 'char' to 'char *'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    C:\Windows\Desktop\C c++\Win32_clock\clock.cpp(111) : error C2664: 'strcat' : cannot convert parameter 1 from 'char' to 'char *'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    Error executing cl.exe.
    (sorry I should have posted only 1 )

    why doesn't this work...I did the itoa function

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    I didn't understand the msdn explanation of sprintf

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's basically printf, but uses a string instead. Actually, I wrote _snprintf, which has a length as well:
    Code:
    char pcBuf[100];
    _snprintf(pcBuf, 100, "Number: %d", iNum);
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Doesn't strcat() require a properlay allocated buffer?
    Harry.

    "From one thing, know ten thousand things."

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That's what I thought, but all the docs are really vague about it so I always use _snprintf (actually I use _tsnprintf, but oh well )
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width