My teacher and i have been having a debate of sorts and this one has me stumped ( since he's actually giving me help now i'm not complaining that my brain is being picked with only one week left in the semester lol) i've never really gotten this coding thing down in the first place, i've just been playing it by ear and hoping that my 'recipe' fits the bill ^_^'. anyway the question i'm stumped on was this : When you get an error message that a variable or an array has not been initialized what does that mean?

To me that means that i've screwed up either when i declared the variable/array or i typed it in wrong in my statements.

This is the code that we are talking about which i did wrong i only got a 60 on it, one because i put the wrong syntax in ( commas instead of brackets for the array rows and coll.) and because i didn't create a function for it and i couldn't check the elements in each array to see if they are equal or not, and failed to return true or false based on the checks.

#include "stdafx.h"


int _tmain(void)
{
// local declarations

int tableA[2][5] = {1,2,3,4,5,6,7,8,9,10}; //tableA
int tableB[2][5] = {1,2,3,4,5,4,7,8,9,10}; //tableB
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;

// Statements

for (a = 0; a < 2; a++)
{
    if ( tableA[0][1] == tableB[0][1])

printf("true");

else

printf("false");
}// for

for (b = 0; b < 2; b++)
{
    if ( tableA[1][1] == tableB[1][1])

printf("true");

else

printf("false");
}// for

for (c = 0; c < 2; c++)
{
    if ( tableA[0][2] == tableB[0][2])

printf("true");

else

printf("false");
}// for

for (d = 0; d < 2; d++)
{
    if ( tableA[1][2] == tableB[1][2])

printf("true");

else

printf("false");
}// for

for (e = 0; e < 2; e++)
{
    if ( tableA[0][3] == tableB[0][3])

printf("true");

else

printf("false");
}// for

for (f = 0; f < 2; f++)
{
    if ( tableA[1][3] == tableB[1][3])

printf("true");

else

printf("false");
}// for

for (g = 0; g < 2; g++)
{
    if ( tableA[0][4] == tableB[0][4])

printf("true");

else

printf("false");
}// for

for (h = 0; h < 2; h++)
{
    if ( tableA[1][4] == tableB[1][4])

printf("true");

else

printf("false");
}// for

for (i = 0; i < 2; i++)
{
    if ( tableA[0][5] == tableB[0][5])

printf("true");

else

printf("false");
}// for

for (j = 0; j < 2; j++)
{
    if ( tableA[1][5] == tableB[1][5])

printf("true");

else

printf("false");
}// for

return 0;
  }// main

after i made the change in my program from commas to brackets ( tableA[0,1] to tableA[0][1]) i got the error that my tables A and B in the statements were being used with out being initialized. so what did i do wrong?

Recommended Answers

All 4 Replies

Oh when it compiles i'm supposed to also have one true for false i think but i tried to do that with a separate code and it didn't work so i stuck with this one.

Can you make smaller but still compilable example of what is going wrong. We likely don't need to look at 100 lines to see the problem. Also, please use code tags.

Can you post the code which is causing the error (using code tags :P), as the code you posted is compiling with me ...

I don't think the code is C++.
I request the MODerators to move the thread to C. I infer no reason for this thread not to be in C forum. It qualifies to be in C forums more than C++ forums

>>as the code you posted is compiling with me ...
May be(perhaps the OP and you are on same implementation) but the code is HIGHLY non-portable and like I said, is non-C++

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.