Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   String vs Char (http://www.go4expert.com/forums/string-vs-char-t3359/)

azygous420 12Mar2007 11:04

String vs Char
 
Hello, I'm new here and need some help understanding the parameters of these two integer types. I recently started programming again and tried to make a hex encoder/decoder. I can't figure out how to make a program analyze two characters in a "char" variable.
This is my program so far...
Code:

int main(int argc, char* argv[])
{
        int code;
        int test;
        int n;
        test = 0;
        int maintest;
        maintest = 0;
        float word;
        char yn;
        n = 0;

        while (maintest == 0)
        {
        fstream file("decode.txt", ios::out);
        char ch, password[51];
        cout << "\nEnter a password (max 8 letters): ";
        cin >> password;
        file << password;
        file.close();
        file.open("decode.txt", ios::in);
        while (test != 1)
        {
                cout << "\nHit 1 to Encode, Hit 2 to Decode: ";
                cin >> code;
                if (code == 1 || code == 2)
                {
                        test = test++;
                }
        }
        if (code == 1)
        {
                file.get(ch);
                while (!file.fail())
                {
                        cout << hex << ch;
                        n = n++;
                        file.get(ch);
                }
        }
        if (code == 2);
        {

        }
        cout << "\nFinish? (Y or N)";
        cin >> yn;
        switch (yn)
        {
                case 'y': maintest = 1;
                case 'n': break;
                default : cout << "\nError";
        }
        }
        return 0;
}

It says it can't convert char to string. So I've tried to use strings instead of char. but i can't get it to input strings correctly. Any help would be greatly appreciated.

shabbir 12Mar2007 12:07

Re: String vs Char
 
Isnt the issue already in discussion here.

DaWei 12Mar2007 17:06

Re: String vs Char
 
Seriously, fellow, replication of a thread doesn't increase attention, it dilutes it. Worse than that, it annoys people so that they decide not to help, anymore.

azygous420 14Mar2007 20:58

Re: String vs Char
 
sry it wasn't showing up so i made a bunch on accident


All times are GMT +5.5. The time now is 04:02.