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; }

11th Aug 2018, 7:45 AM
dario
dario - avatar
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"};
11th Aug 2018, 9:00 AM
Babak
Babak - avatar
+ 2
thank you so much C++ Soldier(Babak)
11th Aug 2018, 9:02 AM
dario
dario - avatar
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.
11th Aug 2018, 9:07 AM
dario
dario - avatar