S
Scott
Will someone please tell me why the first element of the array is not
displayed if the const int amt (see code below) is declared as a
multiple of 4?
If I declare it as 3, or 5 the all elements of the the array are
displayed, if 4 or a multiple is used, it will not cout the first
element.
#include <stdlib.h>
#include <string>
#include <iostream.h>
using namespace std;
void main(){
const int Amt = 4;
char r1[Amt];
char r2[Amt];
cout << "1: " << endl;
cin >> r1;
for (int x = 0; x < Amt; x++)
cout << r1[x];
cout << endl;
cout << "2: " << endl;
cin >> r2;
for (int y = 0; y < Amt; y++)
cout << r1[y];
cout << r1[0];
}
displayed if the const int amt (see code below) is declared as a
multiple of 4?
If I declare it as 3, or 5 the all elements of the the array are
displayed, if 4 or a multiple is used, it will not cout the first
element.
#include <stdlib.h>
#include <string>
#include <iostream.h>
using namespace std;
void main(){
const int Amt = 4;
char r1[Amt];
char r2[Amt];
cout << "1: " << endl;
cin >> r1;
for (int x = 0; x < Amt; x++)
cout << r1[x];
cout << endl;
cout << "2: " << endl;
cin >> r2;
for (int y = 0; y < Amt; y++)
cout << r1[y];
cout << r1[0];
}