0
đ°what's that?!?!?
here is a code that should get char by an array, but when i run the program it show me the alphabet starting by the letter in the array: #include <iostream> #include <string> using namespace std; int main() { int i; int Current_Day = 3; char day[7] = {'L','M','M','G','V','S','D'}; cout<<day[Current_Day]<<" "; day[Current_Day]++; cout<<day[Current_Day]; return 0; }
3 Answers
+ 5
dario
That's what it is. The program consists of a character table (not a string one) to hold 7 uppercase letters.
int Current_Day = 3;
char day[7] = {'L','M','M','G','V','S','D'};
day[Current_Day]; // day[3] == 'G'
day[Current_Day]++; // day[3]++ == 'G' + 1 == 'H'
day[++Current_Day]; // day[4] == 'V'
You probably have included the string header to define a string table as
string day[7] = {"Mon", "Tue", ... , "Sun"};
+ 2
thank you so much C++ Soldier(Babak)
0
int main() {
int i;
int Current_Day = 3;
string day[7] ={"L","M","M","G","V","S","D"};
cout<<day[Current_Day]<<" ";
Current_Day++;
cout<<day[Current_Day];
return 0;
}
this is the final code.