invalid conversion from const char to char

Hi i'm working on a program that is designed to take up storage space on a computer. However i am getting problems on lines 32, 37 and 42 saying "invalid conversion from const char to char"

here is the code:

#include <iostream>
#include <fstream>
#include <cmath>
void rword (char *word)
{
int len = rand () % 99 + 1;
word [len] = 0;
while (len) word [--len] = 'a' + rand () % 26;
}
int main ()
{
using namespace std;

char word[20];
char word2[20];
char bytes ;

int x=0;
int y;
int a=0;
int b=1024;
int c=1024*1024;
int d;
char z;

cout<< "Amount of disk space you wish to take up, kb, mb, gb, type in lower case."<< endl;
cin>> bytes;

if (bytes = 'kb')
{
d=a;
z="kb";
}
else if (bytes = 'mb')
{
d=b;
z="mb";
}
else if (bytes = 'gb')
{
d=c;
z="gb";
}
else
{
cout<< "Incorrect storage amount"<<endl;
}


cout<< "Enter number of "<<z<<" you wish to install as .txt documents";
cin>> y;
y = y*d;
cout<< "This will be just a minute."<<endl;
srand(time(0));
while (x<y)
{
rword(word);
rword(word2);

ofstream myfile;
myfile.open(cout << word << ' ' << word2<<".txt");
myfile << "Storage...";
myfile.close();
cout << word << ' ' << word2 << endl;

//printf ("%s\n", word);

x++;

}



system("pause");
return 0;

}


please can somebody help thanks
[code] "Please use code tags" [/code]
A char can only store 1 character, if you want a string use std::string or char * 1

bytes = 'kb' z="kb"; are invalid (the first one compiles, but it is not what you want)
Also = is assignment, == is comparison. So it should be if (bytes == 'k')

1however the assignment and comparator in that case will be strcpy and strcmp respectively
Topic archived. No new replies allowed.