Why can't this code work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why can't this code work?

I was learning function pointers and I tried to make this code but it is not working, please help. https://code.sololearn.com/cD6JchGXVMNQ/?ref=app

15th Jan 2020, 7:56 AM
Manthan Gohel
Manthan Gohel - avatar
9 Answers
+ 3
You were close. Note strcat updates the original so it must be 30 to hold both 15 character strings. https://code.sololearn.com/c9CuWocUp0Gb
15th Jan 2020, 7:34 PM
John Wells
John Wells - avatar
+ 3
John Wells Thank you so much, I was thinking that didn't I learned the lesson well or what.
15th Jan 2020, 7:41 PM
Manthan Gohel
Manthan Gohel - avatar
+ 3
Array and pointers are interchangable. They always pass pointers. Therefore, I like to see pointers to reflect what is passed. Also, your array numbers can become wrong, when you updated the array definition like I did. It does not really matter because C lets you access c[1000] of char c[2], but it makes the code confusing to others.
15th Jan 2020, 8:01 PM
John Wells
John Wells - avatar
+ 2
John Wells Can you please tell me why did you change the functions and parameters to pointers?
15th Jan 2020, 7:54 PM
Manthan Gohel
Manthan Gohel - avatar
+ 2
John Wells Thank you again! ^-^
15th Jan 2020, 8:04 PM
Manthan Gohel
Manthan Gohel - avatar
+ 1
I worked on this yesterday and today and I got a solution: https://code.sololearn.com/c3eLFB6YcuEa I have just received my C certificate yesterday.
16th Jan 2020, 4:18 PM
Josée Mallah
+ 1
Josée Mallah Why isn't your code opening?
17th Jan 2020, 7:29 AM
Manthan Gohel
Manthan Gohel - avatar
+ 1
https://code.sololearn.com/cv750Xx0UphD This is a new link. The same concept as Mr. Wells
17th Jan 2020, 2:55 PM
Josée Mallah
+ 1
Josée Mallah Congo on your certi(sorry, this is so late), I also received my certi a few days ago
8th May 2020, 10:10 AM
Manthan Gohel
Manthan Gohel - avatar