Well, im just in the learning process of c++
cant seam to make my loop work with 2 simpel choises :(

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
using std::boolalpha;

int main()
 int start;          
 char choise;
 char y;
 char n;   
    cout << "whant to run dec/hex coverter y/n?";
    cin >> choise;
    if (choise = y)
    // decimal number
    int dec;
    cout << "write ur decimal number here\n ";
    cin >> dec;

    // set output format to hex

    cout << "ur hex is\n";

    cout << dec << endl;

    return choise;

    return 0;


any help with whats wrong?

1: programmer (knew that :D)

Edited 3 Years Ago by Nick Evan: Fixed formatting

Classic error:

Line if (choise = y)

This ASSIGNS choise to be y, and then check to see if it is not zero.

Also you don't need the "do" after the if construction.

This tell me either (a) you are using a very old compiler or
(b) you ignore the warning messages. If it is (a) download gcc
and continue. If it is (b) , well the warning cannot be ignored until you are VERY certain you know why they are there.

Finally there is no loop???

Edited 3 Years Ago by Reverend Jim: Fixed formatting

Thx guyes. did get my choise to work now.
cant belive c++ to be THAT sensitive :)

This article has been dead for over six months. Start a new discussion instead.