Hi, I want to save "b" in "a" .
But I don't know how can I do that.
const char *a="";
String b="ABCDEF";
Very thank you.
Hi, I want to save "b" in "a" .
But I don't know how can I do that.
const char *a="";
String b="ABCDEF";
Very thank you.
Why do you want to mix strings (lowercase s) and Strings (uppercase S) ?
actually the variable "*a" is an input of a function and the variable "b" is output of a function.
so I want to save value of variable "b" in variable "*a".
thanks.
leoncorleone:
actually the variable "*a" is an input of a function and the variable "b" is output of a function.
so I want to save value of variable "b" in variable "*a".
thanks.
post your code and I'll show you. I'm not typing out your whole sketch!
char *str1;
char str2[10]="123456789";
Now I want to put str2 in str1.
but how?
leoncorleone:
char *str1;
char str2[10]="123456789";
Now I want to put str2 in str1.
You can not put an array of twenty characters into a pointer to a character.
Whandall:
You can not put an array of twenty characters into a pointer to a character.
you can point to that array with the pointer, however...
char str2[10]="123456789";
char* str1;
str1 = str2;
Serial.println(str1);
BulldogLowell:
you can point to that array with the pointer, however...
How is that connected to
Now I want to put str2 in str1.
?
Whandall:
How is that connected to
?
because str1 now points to what str2 points to.
They are both just pointers ;D
BulldogLowell:
They are both just pointers ;D
No, they are not.
One is a character array (its name can be used as a pointer constant),
the other is a pointer to a character.
The OP seems to have a number of threads on this subject open which is confusing. In addition there has been no complete program posted in any of them or an explanation of why he/she wants to do what they are asking so any answers are not in context and other solutions may be more appropriate.
Whandall:
One is a character array (its name can be used as a pointer constant),
exactly!
as was done
I see a big difference in
"can be used as a pointer constant"
and
"is a pointer"
But that's only my humble opinion.
Whandall:
I see a big difference in"can be used as a pointer constant"
and
"is a pointer"
But that's only my humble opinion.
Tomayto Tomahto.
A rose by any other name would smell as sweet
OP may be looking to pass a pointer to a char array to a function (but who the heck knows what he wants!!!
The fact that your tooth brush could be used to clean the toilet does not make it a toilet brush, does it?
The OP probably has an assignment to enumerate and understand the differences between
Whandall:
[/list]but as you already noted, who knows?
I'm only posting this in order to have the last word.