Solved

little char problem

Posted on 1998-02-16
3
159 Views
Last Modified: 2010-04-10
Why does my function (in VC5) give "cannot convert from 'char *' to 'char'" as an error??

void CRational::ddy ()
{
char Fc [] = {m_Numerator + "/" + m_Denominator};
printf("%s",Fc);
return;
}
0
Comment
Question by:dpms
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
q2guo earned 20 total points
Comment Utility
try this

void CRational::ddy ()
{  
          char Fc[] = {'0'+m_Numerator, '/', '0'+m_Denominator};
          printf("%s",Fc);
          return;
}
0
 
LVL 3

Expert Comment

by:q2guo
Comment Utility
since you are using VC5 why don't you try this

void CRational::ddy()
{
      String a(m_Numerator);
      String c('/');
      String b(m_Denominator);
      String Fc = a+c+b;

      cout << Fc <<endl;
}
0
 

Author Comment

by:dpms
Comment Utility
Ohhhhh! I knew I was doing something really stupid. Couldn't see the forest for the trees, I guess. That's you guys!!!!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now