+ 3

Who knows how to pass char [] to a function?

For example: https://code.sololearn.com/ctpRpn7qal74/?ref=app

11th Sep 2018, 5:13 AM
Andrey Stepanov
Andrey Stepanov - avatar
8 Antworten
+ 1
"A string literal is an array of n constant characters" -> Declare a as const. You can also use a pointer, since an array is technically a reference to the address of it's first element. Example below https://code.sololearn.com/cSInynO7rFB3/?ref=app
11th Sep 2018, 6:06 AM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
+ 2
Yes, but I see now))) Thinks
11th Sep 2018, 6:15 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 2
The example is very good, but the link was not immediately. Now I see, thank you very much
11th Sep 2018, 6:22 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
String type data? Are you sure?
11th Sep 2018, 5:53 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
Problem: the vstudio compiler writes an error
11th Sep 2018, 5:58 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
"A string literal is an array of n constant characters" -> Declare a as const. You can also use a pointer, since an array is technically a reference to the address of it's first element. It's I understand this, but... сan you give a simple example?
11th Sep 2018, 6:12 AM
Andrey Stepanov
Andrey Stepanov - avatar
+ 1
Andrey Stepanov an example for char array? The one above is pretty simple. Is there any part that are confusing? I'll give my best to explain.
11th Sep 2018, 6:13 AM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
0
You are passing a string not a character. You could use a character array or string type data. include string header to use it. https://code.sololearn.com/cNaFLxtqrcdW/?ref=app
11th Sep 2018, 5:16 AM
Akib
Akib - avatar