Trouble displaying array of chars

Hi,
I have asked this question before with no luck, Im making a new thread to simplify things.

- What I want to be able to do is have one point in the code, where I can go and change the symbols I use in the average map. Currently im using these:

#define LessSymbol -1
#define MoreSymbol 1
#define NeitherSymbol 0

But I want to be able to come and change them to something along the lines of

#define LessSymbol @
#define MoreSymbol $
#define NeitherSymbol %

or any random symbol,that will also display in my average map the trouble is, When I do, I get an red underline on the following:

char MoreThanSymbol=MoreSymbol;
char LessThanSymbol=LessSymbol;
char NeitherThanSymbol=NeitherSymbol;

Telling me that @$% are undefined.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#include <stdio.h>
#include <stdlib.h>
/* Declare any constants */
/* Input file name */
#define FILE_NAME "data.csv"
/* Data size */
#define MAX_COLS 20
#define MAX_ROWS 20
#define DEBUG 1
#define LessSymbol -1
#define MoreSymbol 1
#define NeitherSymbol 0
#define MAX_CHAR 3

/*! Main entry point for the program 

\return int
*/
int main (void)
{
	/* Declare any variables */
	/* Stores the data from input from the file */
	float rawData[MAX_ROWS][MAX_COLS];
	float rowAverage[MAX_ROWS];
	float colAverage[MAX_COLS];
	float rowSum[MAX_ROWS];
	float colSum[MAX_COLS];
	char averageMap[MAX_ROWS][MAX_COLS];
	int row = 0;
	int col = 0;
	char MoreThanSymbol=MoreSymbol;
	char LessThanSymbol=LessSymbol;
	char NeitherThanSymbol=NeitherSymbol;
	int rowCount[MAX_ROWS][MAX_CHAR];
	int colCount[MAX_CHAR][MAX_COLS];


	/* Misc vars */
	float tempfloat = 0.0F;
	float tmp = 0.0F;
	char newline = ' ';

	/* Open the file for reading */
	FILE *infp;
	infp = fopen(FILE_NAME,"r");

	/* Check for errors and exit if found */
	if(infp == NULL)
	{
		printf("Error: Failed to open %s for reading\n", FILE_NAME);
		return(1);
	}

	/* Read the file into the data structure */
	for(row = 0; row < MAX_ROWS ; row++)
	{
		/* Read up until the last value */
		for(col = 0; col < MAX_COLS -1; col++)
		{
			if(fscanf(infp,"%f,", &tempfloat) != EOF)
				rawData[row][col] = tempfloat;
			else
			{
				printf("Error: incorrect file format at row %d, col %d.\n", row+1, col+1);
				return(1);
			}
		}
		/* Read the last value and the newline char */
		if(fscanf(infp,"%f%c", &tempfloat, &newline) != EOF)
		{
			/* Check if the last character in the line was a \n otherwise an error occured. */
			if(newline != '\n')
			{
				printf("Error: incorrect file format at line %d. did not find a newline.\n", row+1);
				return(1);
			}
			else
				rawData[row][col] = tempfloat;
			/* Reset the character before the next read. */
			newline = ' ';
		}
	}

	/* Close the file */
	fclose(infp);


	if(DEBUG == 1)
	{
		/* Print the raw data read from the file */
		printf("Raw Data\n");
		for(row = 0; row < MAX_ROWS; row++)
		{
			for(col = 0; col < MAX_COLS; col++)
			{
				printf("%f,", rawData[row][col]);
			}
			printf("\n");
		}

	}

	printf("Row Sum\n");

	for(row = 0; row < MAX_ROWS; row++){
		rowSum[row]=0;
		for(col = 0; col < MAX_COLS; col++){
			rowSum[row] +=rawData[row][col];			
		}
		{
			printf("%f",rowSum[row]);
		}
		printf("\n");
	}

	printf("Col Sum\n");

	for(col = 0; col < MAX_COLS; col++){
		colSum[col]=0;
		for(row = 0; row < MAX_ROWS; row++){
			colSum[col] +=rawData[row][col];
		}
		{
			printf("%f",colSum[col]);
		}
		printf("\n");
	}



	printf("Row Average\n");

	for(row = 0; row < MAX_ROWS; row++){
		rowAverage[row]=0;
		for(col = 0; col < MAX_COLS; col++){
			rowAverage[row]=rowSum[row]/MAX_ROWS;


		}
		{
			printf("%f",rowAverage[row]);
		}
		printf("\n");
	}

	printf("Col Average\n");

	for(col = 0; col < MAX_COLS; col++){
		colAverage[col]=0;
		for(row = 0; row < MAX_ROWS; row++){
			colAverage[col]=colSum[col]/MAX_COLS;
		}
		{
			printf("%f",colAverage[col]);
		}
		printf("\n");
	}

	for(row = 0; row < MAX_ROWS; row++){
		averageMap[row][col]=0;
		for(col = 0; col < MAX_COLS; col++){
			if ((rawData[row][col]>rowAverage[row]) && (rawData[row][col]>colAverage[col]))
				averageMap[row][col]=MoreThanSymbol;
			else if ((rawData[row][col]<rowAverage[row]) && (rawData[row][col]<colAverage[col]))
				averageMap[row][col]=LessThanSymbol;
			else if ((rawData[row][col]<rowAverage[row]) && (rawData[row][col]>colAverage[col])) 
				averageMap[row][col]=NeitherThanSymbol;
			else if ((rawData[row][col]>rowAverage[row]) && (rawData[row][col]<colAverage[col])) 
				averageMap[row][col]=NeitherThanSymbol;

		}
	}

	printf("Average Map\n");
	for(row = 0; row < MAX_ROWS; row++)
	{
		for(col = 0; col < MAX_COLS; col++)
		{
			printf("%c,", (char)averageMap[row][col]);
		}
		printf("\n");
	}
	printf("1's Sum\n");

	for(row = 0; row < MAX_ROWS; row++){
		rowCount[row][0]=0;
		rowCount[row][1]=0;
		rowCount[row][2]=0;
	}
	for(col = 0; col < MAX_COLS; col++){
		colCount[0][col]=0;
		colCount[1][col]=0;
		colCount[2][col]=0;
	}

	for(row = 0; row < MAX_ROWS; row++){
		for(col = 0; col < MAX_COLS; col++){
			if (averageMap[row][col]==MoreSymbol)		
				rowCount[row][0]=rowCount[row][0]+1;
			else if (averageMap[row][col]==NeitherSymbol)
				rowCount[row][0]=rowCount[row][0]+1;
			else if (averageMap[row][col]==LessSymbol)
				rowCount[row][1]=rowCount[row][1]+1;
		}
	}

	printf("Row Count\n");
	for(row = 0; row < MAX_ROWS; row++)
	{
		for(col = 0; col < MAX_CHAR; col++)
		{
			printf("%d,", rowCount[row][col]);
		}
		printf("\n");
	}

	for(col = 0; col < MAX_COLS; col++){
		for(row = 0; row < MAX_ROWS; row++){
			if (averageMap[row][col]==MoreSymbol)		
				colCount[0][col]=colCount[0][col]+1;
			else if (averageMap[row][col]==NeitherSymbol)
				colCount[1][col]=colCount[1][col]+1;
			else if (averageMap[row][col]==LessSymbol)
				colCount[2][col]=colCount[2][col]+1;
		}
	}
	printf("Col Count\n");
	for(col = 0; col < MAX_COLS; col++){
		for(row = 0; row < MAX_CHAR; row++){
			printf("%d,", colCount[row][col]);
		}
		printf("\n");
	}

	/* End the program */
	return 0;
}
closed account (28poGNh0)
why did you post a new thread?

I changed
1
2
3
#define LessSymbol -1
#define MoreSymbol 1
#define NeitherSymbol 0 

to
1
2
3
#define LessSymbol 1
#define MoreSymbol 2
#define NeitherSymbol 0 


also I added
char array[3] = {'@','$','%'};
so I can with it gets those characters

if you write array[NeitherSymbol] you'll get the symbole @
if you write array[LessSymbol] you'll get the symbole $
if you write array[moreSymbol] you'll get the symbole %

The whole code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# include <stdio.h>
# include <stdlib.h>

#define FILE_NAME "data.csv"

#define MAX_COLS 20
#define MAX_ROWS 20
#define DEBUG 1
#define LessSymbol 1
#define MoreSymbol 2
#define NeitherSymbol 0
#define MAX_CHAR 3

int main (void)
{
    float rawData[MAX_ROWS][MAX_COLS];
    float rowAverage[MAX_ROWS],colAverage[MAX_COLS],rowSum[MAX_ROWS],colSum[MAX_COLS];
    int averageMap[MAX_ROWS][MAX_COLS];
    int row = 0,col = 0;
    int MoreThanSymbol = MoreSymbol,LessThanSymbol = LessSymbol,NeitherThanSymbol = NeitherSymbol;
    int rowCount[MAX_ROWS][MAX_CHAR],colCount[MAX_CHAR][MAX_COLS];

    for(int i=0;i<20;i++)
    {
        for(int j=0;j<20;j++)
            rawData[i][j] = (float)(rand()%88+1)/(rand()%5+1);
    }

    if(DEBUG == 1)
    {
        /* Print the raw data read from the file */
        printf("Raw Data\n");
        for(row = 0; row < MAX_ROWS; row++)
        {
            for(col = 0; col < MAX_COLS; col++)
                printf("%0.1f,", rawData[row][col]);
            printf("\n");
        }
    }

    printf("Row Sum\n");

    for(row = 0; row < MAX_ROWS; row++)
    {
        rowSum[row]=0;
        for(col = 0; col < MAX_COLS; col++)
            rowSum[row] +=rawData[row][col];

        printf("%f",rowSum[row]);
        printf("\n");
    }

    printf("Col Sum\n");

    for(col = 0; col < MAX_COLS; col++)
    {
        colSum[col]=0;
        for(row = 0; row < MAX_ROWS; row++)
            colSum[col] +=rawData[row][col];

        printf("%f",colSum[col]);
        printf("\n");
    }

    printf("Row Average\n");

    for(row = 0; row < MAX_ROWS; row++)
    {
        rowAverage[row]=0;
        for(col = 0; col < MAX_COLS; col++)
            rowAverage[row]=rowSum[row]/MAX_ROWS;

        printf("%f",rowAverage[row]);
        printf("\n");
    }

    printf("Col Average\n");

    for(col = 0; col < MAX_COLS; col++)
    {
        colAverage[col]=0;
        for(row = 0; row < MAX_ROWS; row++)
            colAverage[col]=colSum[col]/MAX_COLS;

        printf("%f",colAverage[col]);
        printf("\n");
    }

    for(row = 0; row < MAX_ROWS; row++)
    {
        for(col = 0; col < MAX_COLS; col++)
        {
            if ((rawData[row][col]>rowAverage[row]) && (rawData[row][col]>colAverage[col]))
                averageMap[row][col]=MoreThanSymbol;
            else if ((rawData[row][col]<rowAverage[row]) && (rawData[row][col]<colAverage[col]))
                averageMap[row][col]=LessThanSymbol;
            else averageMap[row][col]=NeitherThanSymbol;
        }
    }

    char array[3] = {'@','$','%'};

    printf("Average Map\n");
    for(row = 0; row < MAX_ROWS; row++)
    {
        for(col = 0; col < MAX_COLS; col++)
            printf("%c,", array[averageMap[row][col]]);

        printf("\n");
    }

    printf("1's Sum\n");

    for(row = 0; row < MAX_ROWS; row++)
    {
        rowCount[row][0]=0;
        rowCount[row][1]=0;
        rowCount[row][2]=0;
    }

    for(col = 0; col < MAX_COLS; col++)
    {
        colCount[0][col]=0;
        colCount[1][col]=0;
        colCount[2][col]=0;
    }

    for(row = 0; row < MAX_ROWS; row++)
    {
        for(col = 0; col < MAX_COLS; col++)
        {
            if (averageMap[row][col]==MoreSymbol)
                rowCount[row][0]=rowCount[row][0]+1;
            else if (averageMap[row][col]==NeitherSymbol)
                rowCount[row][1]=rowCount[row][0]+1;
            else if (averageMap[row][col]==LessSymbol)
                rowCount[row][2]=rowCount[row][1]+1;
        }
    }

    printf("Row Count\n");
    for(row = 0; row < MAX_ROWS; row++)
    {
        for(col = 0; col < MAX_CHAR; col++)
            printf("%d,", rowCount[row][col]);

        printf("\n");
    }

    for(col = 0; col < MAX_COLS; col++)
    {
        for(row = 0; row < MAX_ROWS; row++)
        {
            if (averageMap[row][col]==MoreSymbol)
                colCount[0][col]=colCount[0][col]+1;
            else if (averageMap[row][col]==NeitherSymbol)
                colCount[1][col]=colCount[1][col]+1;
            else if (averageMap[row][col]==LessSymbol)
                colCount[2][col]=colCount[2][col]+1;
        }
    }
    printf("Col Count\n");
    for(col = 0; col < MAX_COLS; col++)
    {
        for(row = 0; row < MAX_CHAR; row++)
            printf("%d,", colCount[row][col]);
        printf("\n");
    }

    /* End the program */
    return 0;
}
Last edited on
Made new thread because no one was posting in old one,

Im sorry I dont understand, im extremely new to c++.

if you write array[NeitherSymbol] you'll get the symbole @
if you write array[LessSymbol] you'll get the symbole $
if you write array[moreSymbol] you'll get the symbole %

Where do I write this?
closed account (28poGNh0)
I did an exhibition above

1
2
3
4
5
6
7
8
9
10
char array[3] = {'@','$','%'};

    printf("Average Map\n");
    for(row = 0; row < MAX_ROWS; row++)
    {
        for(col = 0; col < MAX_COLS; col++)
            printf("%c,", array[averageMap[row][col]]);

        printf("\n");
    }


averageMap[row][col] could be 0,1 or 2 e.i NeitherSymbol ,LessSymbol or moreSymbol

array[averageMap[row][col]] it is like I write array[NeitherSymbol] , array[LessSymbol] or
array[moreSymbol]
Last edited on
You are awesome, I followed that and it works, but one problem, currently it will only display the second two symbols, if you run this, it just shows the first two symbols. not the third one, any idea?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#include <stdio.h>
#include <stdlib.h>
/* Declare any constants */
/* Input file name */
#define FILE_NAME "data.csv"
/* Data size */
#define MAX_COLS 20
#define MAX_ROWS 20
#define DEBUG 1
#define LessSymbol 0
#define MoreSymbol 1
#define NeitherSymbol 2
#define MAX_CHAR 3

/*! Main entry point for the program 

\return int
*/
int main (void)
{
	/* Declare any variables */
	/* Stores the data from input from the file */
	float rawData[MAX_ROWS][MAX_COLS];
	float rowAverage[MAX_ROWS];
	float colAverage[MAX_COLS];
	float rowSum[MAX_ROWS];
	float colSum[MAX_COLS];
	char averageMap[MAX_ROWS][MAX_COLS];
	int row = 0;
	int col = 0;
	char MoreThanSymbol=MoreSymbol;
	char LessThanSymbol=LessSymbol;
	char NeitherThanSymbol=NeitherSymbol;
	int rowCount[MAX_ROWS][MAX_CHAR];
	int colCount[MAX_CHAR][MAX_COLS];


	/* Misc vars */
	float tempfloat = 0.0F;
	float tmp = 0.0F;
	char newline = ' ';

	/* Open the file for reading */
	FILE *infp;
	infp = fopen(FILE_NAME,"r");

	/* Check for errors and exit if found */
	if(infp == NULL)
	{
		printf("Error: Failed to open %s for reading\n", FILE_NAME);
		return(1);
	}

	/* Read the file into the data structure */
	for(row = 0; row < MAX_ROWS ; row++)
	{
		/* Read up until the last value */
		for(col = 0; col < MAX_COLS -1; col++)
		{
			if(fscanf(infp,"%f,", &tempfloat) != EOF)
				rawData[row][col] = tempfloat;
			else
			{
				printf("Error: incorrect file format at row %d, col %d.\n", row+1, col+1);
				return(1);
			}
		}
		/* Read the last value and the newline char */
		if(fscanf(infp,"%f%c", &tempfloat, &newline) != EOF)
		{
			/* Check if the last character in the line was a \n otherwise an error occured. */
			if(newline != '\n')
			{
				printf("Error: incorrect file format at line %d. did not find a newline.\n", row+1);
				return(1);
			}
			else
				rawData[row][col] = tempfloat;
			/* Reset the character before the next read. */
			newline = ' ';
		}
	}

	/* Close the file */
	fclose(infp);


	if(DEBUG == 1)
	{
		/* Print the raw data read from the file */
		printf("Raw Data\n");
		for(row = 0; row < MAX_ROWS; row++)
		{
			for(col = 0; col < MAX_COLS; col++)
			{
				printf("%f,", rawData[row][col]);
			}
			printf("\n");
		}

	}

	printf("Row Sum\n");

	for(row = 0; row < MAX_ROWS; row++){
		rowSum[row]=0;
		for(col = 0; col < MAX_COLS; col++){
			rowSum[row] +=rawData[row][col];			
		}
		{
			printf("%f",rowSum[row]);
		}
		printf("\n");
	}

	printf("Col Sum\n");

	for(col = 0; col < MAX_COLS; col++){
		colSum[col]=0;
		for(row = 0; row < MAX_ROWS; row++){
			colSum[col] +=rawData[row][col];
		}
		{
			printf("%f",colSum[col]);
		}
		printf("\n");
	}



	printf("Row Average\n");

	for(row = 0; row < MAX_ROWS; row++){
		rowAverage[row]=0;
		for(col = 0; col < MAX_COLS; col++){
			rowAverage[row]=rowSum[row]/MAX_ROWS;


		}
		{
			printf("%f",rowAverage[row]);
		}
		printf("\n");
	}

	printf("Col Average\n");

	for(col = 0; col < MAX_COLS; col++){
		colAverage[col]=0;
		for(row = 0; row < MAX_ROWS; row++){
			colAverage[col]=colSum[col]/MAX_COLS;
		}
		{
			printf("%f",colAverage[col]);
		}
		printf("\n");
	}

	for(row = 0; row < MAX_ROWS; row++){
		averageMap[row][col]=0;
		for(col = 0; col < MAX_COLS; col++){
			if ((rawData[row][col]>rowAverage[row]) && (rawData[row][col]>colAverage[col]))
				averageMap[row][col]=NeitherSymbol;
			else if ((rawData[row][col]<rowAverage[row]) && (rawData[row][col]<colAverage[col]))
				averageMap[row][col]=LessThanSymbol;
			else if ((rawData[row][col]<rowAverage[row]) && (rawData[row][col]>colAverage[col])) 
				averageMap[row][col]=NeitherThanSymbol;
			else if ((rawData[row][col]>rowAverage[row]) && (rawData[row][col]<colAverage[col])) 
				averageMap[row][col]=NeitherThanSymbol;

		}
	}
	
	char array [3] = {'@','$','^'};

	printf("Average Map\n");
	for(row = 0; row < MAX_ROWS; row++)
	{
		for(col = 0; col < MAX_COLS; col++)
		{
			printf("%c,", array[averageMap[row][col]]);
		}
		printf("\n");
	}
	printf("1's Sum\n");

	for(row = 0; row < MAX_ROWS; row++){
		rowCount[row][0]=0;
		rowCount[row][1]=0;
		rowCount[row][2]=0;
	}
	for(col = 0; col < MAX_COLS; col++){
		colCount[0][col]=0;
		colCount[1][col]=0;
		colCount[2][col]=0;
	}

	for(row = 0; row < MAX_ROWS; row++){
		for(col = 0; col < MAX_COLS; col++){
			if (averageMap[row][col]==MoreSymbol)		
				rowCount[row][0]=rowCount[row][0]+1;
			else if (averageMap[row][col]==NeitherSymbol)
				rowCount[row][0]=rowCount[row][0]+1;
			else if (averageMap[row][col]==LessSymbol)
				rowCount[row][1]=rowCount[row][1]+1;
		}
	}

	printf("Row Count\n");
	for(row = 0; row < MAX_ROWS; row++)
	{
		for(col = 0; col < MAX_CHAR; col++)
		{
			printf("%d,", rowCount[row][col]);
		}
		printf("\n");
	}

	for(col = 0; col < MAX_COLS; col++){
		for(row = 0; row < MAX_ROWS; row++){
			if (averageMap[row][col]==MoreSymbol)		
				colCount[0][col]=colCount[0][col]+1;
			else if (averageMap[row][col]==NeitherSymbol)
				colCount[1][col]=colCount[1][col]+1;
			else if (averageMap[row][col]==LessSymbol)
				colCount[2][col]=colCount[2][col]+1;
		}
	}
	printf("Col Count\n");
	for(col = 0; col < MAX_COLS; col++){
		for(row = 0; row < MAX_CHAR; row++){
			printf("%d,", colCount[row][col]);
		}
		printf("\n");
	}

	/* End the program */
	return 0;
}
I fixed it, i used your better code for the comparison of the main table. Thank you so much for your help man. ur the best
haha, another problem arises...

If I want to go back to the 1,-1 and 0. while using this code, it doesn't show the negative "-" when I print it, Is there a fix to this?
closed account (28poGNh0)
That because you did not realy lesten when I advise you to use

1
2
3
4
5
6
7
8
9
10
11
for(row = 0; row < MAX_ROWS; row++)
{
    for(col = 0; col < MAX_COLS; col++)
    {
        if ((rawData[row][col]>rowAverage[row]) && (rawData[row][col]>colAverage[col]))
            averageMap[row][col]=MoreThanSymbol;
        else if ((rawData[row][col]<rowAverage[row]) && (rawData[row][col]<colAverage[col]))
            averageMap[row][col]=LessThanSymbol;
        else averageMap[row][col]=NeitherThanSymbol;
    }
}


instead of

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
for(row = 0; row < MAX_ROWS; row++)
{
    averageMap[row][col]=0;
    for(col = 0; col < MAX_COLS; col++)
    {
        if ((rawData[row][col]>rowAverage[row]) && (rawData[row][col]>colAverage[col]))
            averageMap[row][col]=NeitherSymbol;
        else if ((rawData[row][col]<rowAverage[row]) && (rawData[row][col]<colAverage[col]))
            averageMap[row][col]=LessThanSymbol;
        else if ((rawData[row][col]<rowAverage[row]) && (rawData[row][col]>colAverage[col])) 
            averageMap[row][col]=NeitherThanSymbol;
        else if ((rawData[row][col]>rowAverage[row]) && (rawData[row][col]<colAverage[col])) 
            averageMap[row][col]=NeitherThanSymbol;
    }
}


I did change, it works fine now. But how would i get the negitive sign in the -1 to display.

char array [3] = {'$','-1','1'};

If I use this, it results in $ and 1, no negitives show up
closed account (28poGNh0)
That because we put only one character betwen single quotes

here '-1' You putting two charaters so You cannot do this

try only one character
I need it to display -1, is it at all possible?
By the way, you are awesome and thank you very much for your help so far, i appreciate this alot.
closed account (28poGNh0)
Alter this one with the other

1
2
3
4
5
6
7
8
9
10
char array[3][3] = {"@","$","-1"};

    printf("Average Map\n");
    for(row = 0; row < MAX_ROWS; row++)
    {
        for(col = 0; col < MAX_COLS; col++)
            printf("%s,", array[averageMap[row][col]]);

        printf("\n");
    }
You are the best man. Thank you very much
closed account (28poGNh0)
You're welcome
Topic archived. No new replies allowed.