View Single Post
Old Jul 19th, 2005, 11:25 AM   #1
Broax
Hobbyist Programmer
 
Broax's Avatar
 
Join Date: Jan 2005
Location: Porto, Portugal
Posts: 142
Rep Power: 4 Broax is on a distinguished road
Send a message via MSN to Broax
Invalid Conversion??

Hello all!

I'm starting c++ from scratch and after the 2nd lesson I decided to make a nice little program just to test what I've learned so far... But I got the following error:
Quote:
Originally Posted by Bloodshed DEV C++
C:\Programas\Dev-Cpp\teste dia 1.cpp In function `int main()':
19 C:\Programas\Dev-Cpp\teste dia 1.cpp invalid conversion from `const char*' to `char'
20 C:\Programas\Dev-Cpp\teste dia 1.cpp invalid conversion from `const char*' to `char'
With the following code:
/*
  Name: Test - Day 2
  Copyright: Broax.com
  Author: Broax
  Date: 19-07-05 01:57
  Description: Simple C++ program that tests my knowledge of simple program structure, variables, data types and constants. 
*/

//Pre-Processor Instructions:
#include <iostream> //iostream: Library that allows Input and Output of data into a stream of information.
#define dc42 "Forty-Two" //Defines a value as a constant macro.

//Global Variable Declaration (Obsolete in this case)
int my_age = 20;

int main () //start of "main" function:
{
    //Local Variables:
            const char lang = "C++";
            char me = "Broax";
    //instructions:
                   std::cout << me << " is learning " << lang << " at the age of " << my_age << "...\bWhy?...\b\t" << dc42;
    //End of instruction set:
          return 0;
    //End of function:
          }

Anyway, I've ran it through my head a million times, but I don't understand where I went wrong!! I've left the comments in so that you can see what I was trying to do when...

BTW, I didn't use the "using namespace std" thing, because that's a bit down the road of the tutorial and I thought I'd leave it 'till then. I don't like to do stuff that I don't fully understand...

One last thing... Just for the fun I've made this!
#include <iostream>

int teste = 42;

int main ()
{
    std::cout << "\xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf\n";
    std::cout << "\xb3 Check out the cute little \xb3 Box!!! \xb3\n";
    std::cout << "\xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9\n";
    std::cout << "\n";
    std::cin.get();
    return 0;
}
__________________
PORTUGALPORTUGA
PORTUGALPORTUGA
PORTUGALPORTUGA
PORTUGALPORTUGA
PORTUGALPORTUGA
Broax is offline   Reply With Quote