Can i change a code to C directly from C++ coding ? Or i have to rewrite the code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Can i change a code to C directly from C++ coding ? Or i have to rewrite the code

7th Sep 2017, 4:16 PM
Sandeep Garai
Sandeep Garai - avatar
4 Answers
+ 4
U need to make few changes in the code as C and C++ have different different syntax. No need to rewrite the entire code again. Hope this helps😁
7th Sep 2017, 4:17 PM
Anurag Desai
Anurag Desai - avatar
+ 9
you can modify the code easily because syntax is same and u just need to change headerfiles & some functions. for e.g., printf("%d",a); to cout<<a;
7th Sep 2017, 4:18 PM
P R
P R - avatar
+ 2
You nearly can. If you have done some malloc without casting, you'll have to add the cast Good C practice is not good c++ practice though
7th Sep 2017, 4:18 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
You will definitely have to make some changes because in C language we require type specifiers for eg Printf("%d",n); But in C++ we dont require type specifiers just simply the variable name irrespective of its datatype. For eg Cout<<n; Hope i was clear to you.
4th Oct 2017, 5:28 AM
dhiman mishra
dhiman mishra - avatar