Well, what IS the difference between
char* cnArray[80]
and
char cnArray[80]
?
My program is collectively about 230 lines long, with 3 or 4 various header files. I'm aware that newbies who insist on ambiguity are the scourge of forums like these, but I'm trying to hold off on posting pages of code unless it's absolutely necessary.
For the record, I have gotten my program to function correctly even with my lacking knowledge of arrays (which I am obviously using quite frequently). I keep a project that is essentially a blank slate open where I will spend 5 minutes typing in simplistic code to test certain postulates of mine about arrays because I haven't been able to correctly understand them when I read about them.
Edits begin here.
Fuck it. I don't want to aggravate the people who make this community function (lol. developer pun.) Lets do this.
1 2
|
const int MAX=80;
char cnArray[MAX];
|
^declared in a namespace residing in a header file that is #included in main.cpp
GetInput();
^the 1st line of void main(){...
1 2 3 4 5
|
void GetInput(){ //this will get input from the command line and remove the spaces from it.
std::cout <<"Enter problem." << std::endl;
std::cin.getline(cnArray,MAX);
RemoveSpace(cnArray);
return;}
|
^fx declared in the same namespace as the 1st piece of code in this post.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
void RemoveSpace(char* nospacesArray){
for(counterA=0,counterB=0,counterC=1;counterA!=MAX;counterA++,counterB=counterA,counterC=counterB+1){
if(int(nospacesArray[counterA])==32){
while(counterB!=MAX){
nospacesArray[counterB]=nospacesArray[counterC];
counterB++,counterC++;}
counterB=counterA;
counterC=counterB+1;
counterA--;}
else
continue;}
return;
}
|
^fx declared in the same namespace as the 1st piece of code in this post.
I've tested my code and it has worked. But in the future I can certainly see how my roundabout bootleg way of working with arrays might be my doom.
Edit #2. Don't poke fun at my pitifully excessive function to remove the spaces from a c-string... I did it all by myself from scratch because, when I looked it up, I couldn't understand why other peoples functions, designed to do the same thing, worked. And I don't generally like using things if I don't fully understand them. I'm sure the universe is getting a kick out of the irony of this thread.