Arduino Memory FULL, I don't know why

I try very hard not to use the String class, and I haven't used a goto in the last fifteen years, so I'm not sure I'm the best person to ask.

Me too :wink:

Not true of all Arduino. Especially as the OP says he is using a Mega 2560, which does not work this way.

It runs code from the program flash and is incapable of running code that is stored in RAM.

It is basically a Harvard architecture machine but slightly modified so that code ruining in one sector of the memory map can actually write to program memory. This is known as the "boot sector" because it is where the boot loader code is.

Got it.

Who or what taught you to use goto statements?

Not sure if you have changed it since the original post, but your PROFILE.h code declares two arrays, Username[15] and Password[15]. There are a few places in the code where you are exceeding the bounds of those arrays by writing to element 15, which does not exist.

lol I mean I never wanted to use goto statements but I had no option but to use them because I couldn't call functions again and again is User does this or that and also because even if I could do I would have restore all the initial states of most variables and arrays.
I am not sure if you're just asking or saying that it's not best practice but I just wanna answer your question, I looked up on youtube how to use goto statements.

Hey david, Yes I have changed the code since original post I figured out that I had declared 15 elements in arrays and was using more than 15 in code, so I fixed it by increasing one element more, Now I don't have waggressive loop optimizations error. BUT I still have a problem with one of my functions called RemoveChar of class profile, I know what's wrong with it, basically that function removes white spaces from the string I think those so many iterations are very inefficient but it works only problem is that somehow something is adding white spaces at the end of the string even thought it is removing white spaces in between string characters. I simply tried to substract 1 or 2 from the for loop but it still doesn't solve the problem. Can anyone suggest me what's going on with it?

Just wondering why do you avoid string class, I know why would anyone not use goto but idk about that class

I don't have time tonight to look over the code too closely.
When you are removing spaces from between characters, is the code properly recognizing that the text now contains less characters?

There is no program that can be written with goto statements that cannot be written more coherently with branching logic, iterative logic, and functional logic.
Goto became unnecessary and quite undesirable close to 60 years ago, and are only part of C because of the language that it modeled.
Removing goto fixed so many issues and is the first place I'd start.

Yes the code is properly organizing them as I expect, it completely removes all white spaces in between those characters but not after those characters

How are you determining how many characters are in the text? Does not appear to be a normal null-terminated string. Do you have a counter somewhere to keep track of the length?

Yes you're actually right programs can be written with proper planning, but since I am just a learner and I just wanted to improve my skills so I took on this project of making a UI but ended up realizing that I didn't plan that well, and realized that I've screwed up, I didn't want to restructure everything cuz I was little lazy I guess as I would have to rewrite a lot of things, but it was worthy experience because I can plan better now. But do you think it is doable without goto in my case where I have used it?

Always yes.

It's bit inefficient but I just start a loop where it detects first non white space character and then continues counting until it detects a white space which means end of the string, but since it is possible that user can leave a single white space so it doesn't just stop as soon as it finds the white space it then again checks if there's any non white space character there if not it exits if yes then counts again from there

Won't I have to change my code structure and algorithm a bit to do that? like I know task can be done without goto but not the algo I guess, you know what I mean right?

yes it's a counter that keeps track, I am not using any null character that is usually sent at the end of each string.

It looks like you are using goto in place of a conditional loop.

Yes it's not a conditional loop, actually I basically divided these main tasks into functions
1)Registration as one function Registration()
2)Logging in as Login()
3)Recovery as Recover();
4) User Settings as Setting();

so then I started making these functions and I didn't realize but then it got bigger and bigger and took a lot of processes and functions like Register, Verify, UserInfo, etc then I had no idea how to do it in logical algorithm instead of jumping around the code.

UserProfile() named function is the function which calls these functions and then these functions call some other functions from the class to assist with storing data etc.