Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. whatz wrong?

whatz wrong?

Scheduled Pinned Locked Moved Managed C++/CLI
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    char *t1="Tommy"; char *t2="Lee"; strcat(t1,t2); whatz wrong with the above code? i'm using VC6.0.. the application gets terminated.. if i use char[] its working.... then y not char*? whatz the difference??

    C T 2 Replies Last reply
    0
    • A Anonymous

      char *t1="Tommy"; char *t2="Lee"; strcat(t1,t2); whatz wrong with the above code? i'm using VC6.0.. the application gets terminated.. if i use char[] its working.... then y not char*? whatz the difference??

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      MOTLEY !!!! Sorry. First of all, you're asking in the C++/CLI board, which is for managed C++. Yeah, the new name makes it less clear. Secondly, you should prefer to use the std::string class, or even CString, rather than manipulating char *. Finally, the first argument passed into strcat should contain enough space after the null terminator to make room to copy in the second string. This is the sort of crap that makes C string handling really sucky, compared to using std::string. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • A Anonymous

        char *t1="Tommy"; char *t2="Lee"; strcat(t1,t2); whatz wrong with the above code? i'm using VC6.0.. the application gets terminated.. if i use char[] its working.... then y not char*? whatz the difference??

        T Offline
        T Offline
        Tim Zorn
        wrote on last edited by
        #3

        char *t1="Tommy"; char *t2="Lee"; strcat(t1,t2); //wrong char t1[]="Tommy"; char t2[]="Lee"; strcat(t1,t2); //right char*'s are pointers to an array of char's

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups