Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assertion Failure in cout.

Status
Not open for further replies.

djimm100

Programmer
May 19, 2003
8
0
0
US
I have this statement in a function:

Code:
cout << m << &quot;, XSet ID# &quot; << temp_xid;

m is a pointer to a string. temp_xid is an unsigned long. For some reason, an assertion failure is occurring inside cout every time I try to pass a numeric constant or variable. temp_xid, long, int, short and double cause this problem, but inserting a char does not.

Any ideas?
 
>> m is a pointer to a string

Is m is of type 'char*'?

A common mistake is to pass STL string objects into functions that are expecting a C-style string (i.e., char*). If that is the case, then you need to call basic_string::c_str() on the string object.

Thus, if this was indeed your mistake, the line above would be written

[tt]cout << m.c_str() << &quot;, XSet ID# &quot; << temp_xid;[/b]

[sub]I REALLY hope that helps.[/sub]
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top