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;
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);
[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