hello I'm a little confused as to why this isn't working, I think it may be the IDE/compiler I use which is Dev c++ 4 (I didn't know what other group to post this in) Its a snippet from a larger program I'm using I wanted to test what exactly wasn't working. I have a 2d array and to test it you enter four values, 2 per element. If you enter 123 and 4 the output should be 1234, but for some reason the first element is overwritten by the second. heres the code:
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include "conio.h"
#include <iomanip.h>
#include <string>
using namespace std;
int main()
{
char test[2,2];
int a=0 ;
int b=0;
do {
b=0;
do {
test[a,b]= getche();
b++;
}while (b <=1);
a++;
} while (a <=1);
int x=0;
for (;x <= 1;x++){
for (int y=0; y <= 1; y++){
cout << test[x,y];
endl;
}
}
system("PAUSE");
return 0;
}
thanks for any suggestions
Beholder
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include "conio.h"
#include <iomanip.h>
#include <string>
using namespace std;
int main()
{
char test[2,2];
int a=0 ;
int b=0;
do {
b=0;
do {
test[a,b]= getche();
b++;
}while (b <=1);
a++;
} while (a <=1);
int x=0;
for (;x <= 1;x++){
for (int y=0; y <= 1; y++){
cout << test[x,y];
endl;
}
}
system("PAUSE");
return 0;
}
thanks for any suggestions
Beholder