Re: What's wrong ?? LNK2019 error (Unresolved externals)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: David Olsen (qg4h9ykc5m_at_yahoo.com)
Date: 07/29/04


Date: Thu, 29 Jul 2004 11:58:04 -0700

Jason Jacob wrote:
> But another question, as from my code, I have set the cInput (char
> array) to only a length of 10, but how come I can enter a string of
> more than 20 or even 40 characters ?? (It looks quite illogical, but
> somehow it works fine till now)

You are overflowing the buffer and stomping on memory you don't own.
Don't do that!!! Really bad things can happen. You are just unlucky
that it seems to have worked so far.

In today's C++, you should never use char arrays to manipulate strings.
Doing so can be really tedious, and it's just too easy to forget how big
your buffer is and write past the end of it. Always use a string class
instead. I prefer std::string, but any class, even CString, is better
than using char arrays.

-- 
David Olsen
qg4h9ykc5m@yahoo.com


Relevant Pages

  • Re: split a string
    ... But this reads a string into a single char ... Check fgetsfrom the Standard C Library as a way to get string input ... pointer to a pointer to a char. ... To handle arrays remotely. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Parsing between a character and sysmbol
    ... I did say was that your statement of avoiding arrays inside loops whenever ... creating new String objects. ... This is what I got inside its main loop (I'm not ... the "-" char into an array of chars. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: What makes a class view as an embed object
    ... In many string classes, such as ... there are converters to pointer to const char. ... value of the string class object. ... MyString mystring; ...
    (alt.comp.lang.learn.c-cpp)
  • Re: insert a char in the middle of a string
    ... > I have to insert a char in the middle of a string, ... chars you could implement them as lists of characters, ... arrays that are broken and re-combined, ...
    (comp.lang.c)
  • Re: char vs int
    ... 'a' is a character constant. ... A variable of type char can ... of them instead of int arrays. ... concept of pointers. ...
    (comp.lang.c)