I'm trying to make variables to hold strings of text and am getting the following errors:
Line 14: 'byte' undeclared (first use this function)
Line 14: (Each undeclared identifier is reported only once
Line 14: for each function it appears in.)
Line 18: 'byte2' undeclared (first use this function)
Here's my code:
There's more to the program but I'm only posting what I think is pertinent to the problem at hand and for the sake of space.Code:#include <iostream.h> #include <string.h> using namespace std; int main() { string byte, byte2; char answer; int size; cout<<"This program is design to convert computer memory sizes.\n"; start: cout<<"What is the base byte? (b,kb,mb,gb,tb) "; cin>> byte; cout<<"How many of the base byte? "; cin>> size; cout<<"What would you like to convert it to? "; cin>> byte2; if ( byte == "b" ) { if ( byte2 == "kb" ) { cout<<"There are "<< (size/1024) <<"kilobytes in "<< size <<"bytes\n"; } if ( byte2 == "mb" ) { cout<<"There are "<< ((size/1024)/1024) <<"megabytes in "<< size <<"bytes\n"; } if ( byte2 == "gb" ) { cout<<"There are "<< (((size/1024)/1024)/1024) <<"gigabytes in "<< size <<"bytes\n"; } if ( byte2 == "tb" ) { cout<<"There are "<< ((((size/1024)/1024)/1024)/1024) <<"terabytes in "<< size <<"bytes\n"; } }
Thanks.