• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

fprintf error

I'm trying to write the value of curCommand into the file pointed to by m_file.
The type of curCommand is String.

When I run the program using the line:  fprintf ( m_file, "%s\n", curCommand ) ;
I get in the file garbage instead of the string in curCommand.

When I compile the program using the line:  fprintf ( m_file, "%s\n", (char*)curCommand ) ;
I get the error below:

error C2440: 'type cast' : cannot convert from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'char *'

How can I print the data stored in the String argument ? note that in the debug winow I see that curCommand has the correct value.

Thanks.
0
chayahd99
Asked:
chayahd99
1 Solution
 
chayahd99Author Commented:
After looking for 2 days, I found the solution: curCommand.c_str()
It was in http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20164790.html

I will ask for a refund.
0
 
RomModCommented:
The question has been PAQ'd and the 30 points have been refunded.
RomMod
Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now