Puppet_Sock wrote:
> So, I'm madly coding away, and my fingers stutter, and I produce this.
> (mfirstToken is a std::string object.)
>
> if(m_firstToken.c_str()[0] == 'M' || m_firstToken.c_str().c_str()[0]
> == 'T')
> {
> // ... other code here
> }
>
> And of course my compiler barfs over it. But what it tells me is
> .c_str requires an object. Had to peer at that for like 20 minutes
> to spot the stupid mistake. I should not drink and code.
> Socks
>
I'm pretty sure that everyone on this list has a stupid syntax
error/logic error story.
Mine is from the first piece of code I wrote as a professional (C only,
C++ didn't exist back then).
int init()
{
int i;
for (i = 0 ; i < LIMIT ; i++);
{
/* initialize array[i] here */
}
}
Took me forever to figure out why nothing was getting initialized, and
some memory was getting corrupted.
|