void cString(String csn) {
//Initializes a character array string
char csn[2] = "A";
}
When I compile it I get the error message
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Due (Programming Port)"
C:\Users*****\Documents\Arduino\testMem\testMem.ino: In function 'void cString(String)':
testMem:14:13: error: declaration of 'char csn [2]' shadows a parameter
char csn[2] = "A";
^
exit status 1
declaration of 'char csn [2]' shadows a parameter
How can I name this variable the contents of another variable, and if I can't do that what else can I do?
I would also like to keep it after the function ends, but I'm not sure if I could do that with return or not
micahsuess: How can I name this variable the contents of another variable, and if I can't do that what else can I do?
I would also like to keep it after the function ends, but I'm not sure if I could do that with return or not
Do you mean that you want the name of the variable to be taken from the contents of the String? That cannot be done, variable names do not exist at runtime.
david_2018:
Do you mean that you want the name of the variable to be taken from the contents of the String? That cannot be done, variable names do not exist at runtime.
What is it that you are trying to do?
Yes, but is there still a way I can make variables (even if they're not real variables) or do I have to initialize them before I compile it
Still, you have not explained clearly what you are trying to do. Please explain step by step, an example would be great, too. "I want a string" isn't nearly enough unless you happen to be you.
aarg:
Still, you have not explained clearly what you are trying to do. Please explain step by step, an example would be great, too. "I want a string" isn't nearly enough unless you happen to be you.
OK so first I was trying to make a function that turns a string into a character array using cstring as shown in
But then I needed to make a function that creates the cstring so info can be put into it afterwards, my problem is is that you can't create a variable after the code compiles, so I want to know an alternative
I am going to post another thread because I have another idea