+ 1

Why is the output an integer even i declared it as char

https://code.sololearn.com/cxymtWCVLTgg/?ref=app

17th Mar 2020, 7:17 AM
Y AD Ù
Y AD Ù - avatar
10 Réponses
+ 1
Ohh okay ~ swim ~ i didn't know that the array will be destroyed after the function call return.. I tried to make sense of malloc and all but didnt work out...im jst a beginner and will see to that..
17th Mar 2020, 11:39 AM
Y AD Ù
Y AD Ù - avatar
0
~ swim ~ i didnt get you as a whole..yet ill try..
17th Mar 2020, 8:10 AM
Y AD Ù
Y AD Ù - avatar
0
Ok ~ swim ~ now i have modified the code with my understanding..and why cant it work now.. Heres my explanation The function returns wrd2 which is adress of the first letter of the charector arrar 'wrd2'.. So my char function returns an adress So i modified: char strtlwr()--> char *strlwr() Since it returns an address it will be saved to the pointer function lyk: Char *strlwr()=address So wen we do: Printf("%s",strlwr("HJJKJj")); as you said her%s has an address to read and will print the array.. So where am i wrong here..? Thnks in advance
17th Mar 2020, 11:18 AM
Y AD Ù
Y AD Ù - avatar
0
okay ~ swim ~ i have modified it... is this what your talking about.,?
17th Mar 2020, 12:10 PM
Y AD Ù
Y AD Ù - avatar
0
~ swim ~ and why should that be..we are assingning ptr with a value,,,and y shld it be a NULL?
17th Mar 2020, 12:26 PM
Y AD Ù
Y AD Ù - avatar