So yeh, I'm kind of new to c :). So, as far as I know, and array initialized to 0 will stay at 0 unless something is stored by some other function or command. so I have and array here(imgSet) that when I tell my program to print out elements individually, its giving some wierd things, depending on how I want them to be printed( i.e. characters, int, etc...)
I can't seem to find any cases where this has happened anywhere else and I wanted to see what some pro's would think about this.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
// setting up array and a few integers i may need//
char imgSet[10][65538] = {0};
char *filename[80];
char *menu;
char l,L,r,R,p,P,a,A,h,H,v,V,t,T,d,D,m,M,q,Q;
char *menuinput=0;
int x,i,j,vSize,hSize;
int control1 = 0;
int control2 = 0;
l = 'l';
L = 'L';
r = 'r';
R = 'R';
p = 'p';
P = 'P';
a = 'a';
A = 'A';
h = 'h';
H = 'H';
v = 'v';
V = 'V';
t = 't';
T = 'T';
d = 'd';
D = 'D';
m = 'm';
M = 'M';
q = 'q';
Q = 'Q';
menu = ("*****OPTION*****MENU***** \nL: Load image \nR: Remove image \nP: Print image \nA: Average image \nH: Horizontal derivative\nV: Vertical derivative\nT: compute hisTogram\nD: search Digram\nM: local Maxima\nQ: Quit program\n*************************\n\n");
//void readImage(const char *fname, unsigned char *img);
while((control1 == 0))
{
printf("%senter option:",menu);
scanf("%s", &menuinput);
if((menuinput == l) ||(menuinput == L))
{
printf("Enter filename:");
scanf("%s",&filename);
printf("%s\n\n",filename);
i = 0;
while (i<10)
{
if (imgSet[i] == 0)
{
printf("empty %d\n",i);
i += 1;
}
else
{
j = i;
printf("%c ",imgSet[i]);
printf("j is %i\n",j);
i += 1;
}
}
printf("\n");
//readImage(filename,imgSet[i]);
//i = 10;
}
else if((menuinput == 'r') ||(menuinput == 'R'))
printf("input is %s\n\n",menuinput);
else if((menuinput == 'a') ||(menuinput == 'A'))
printf("input is %s\n\n",menuinput);
else if((menuinput == 'p') ||(menuinput == 'P'))
printf("input is %s\n\n",menuinput);
else if((menuinput == 'h') ||(menuinput == 'H'))
printf("input is %s\n\n",menuinput);
else if((menuinput == 'v') ||(menuinput == 'V'))
printf("input is %s\n\n",menuinput);
else if((menuinput == 't') ||(menuinput == 'T'))
printf("input is %s\n\n",menuinput);
else if((menuinput =='d') ||(menuinput == 'D'))
printf("input is %s\n\n",menuinput);
else if((menuinput == 'm') ||(menuinput == 'M'))
printf("input is %s\n\n",menuinput);
else if((menuinput == 'q') ||(menuinput == 'Q'))
printf("Terminating\n\n",control1 = 1);
else
;
}
}
When I run this I am putting L as my input and anything as a file name since it isnt reading anything yet. I set it to output something the contents of the array and the index it is in as the j variable.
this is the output it is giving me in its current state.
L j is 0
N j is 1
P j is 2
R j is 3
T j is 4
V j is 5
X j is 6
Z j is 7
\ j is 8
^ j is 9
Help please. Thank you