Why long instead of int creates "Compilation error" in C language? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why long instead of int creates "Compilation error" in C language?

So I read that it's better to use LONG instead of INT now, cuz 64bit systems use LONG by default and don't have to convert INT to LONG. But if I use it in CODE PLAYGROUND, it makes "Compilation error"... Can anybody explain why? https://code.sololearn.com/cR8EWNanRW65/#c And 1 more question. What software should I use to code on Windows 10? I have CLion w/ VS 2017, but input commands don't work in C Language for some reason.

19th Aug 2018, 5:08 PM
Alex “Rusack” Averin
Alex “Rusack” Averin - avatar
5 Answers
+ 1
Alex “Rusack” Averin as I am on mob application, could not go through much more details and change all int to long.... but below is my observation and with those update, I changed most of int to long and it worked: //include time.h when you are using time(null) // don't change to long main... it should be int main as it is designated start of code // changing to long from int should be accompanied by changing %d to %li for each printf statement // in damage_inp function, there are six elements into declared array of size 5...remove last element //int weapon[5] = {1, 2, 3, 4, 5, 0}; // in damage_inp , default return case should be there... add something like return(weapon[0]); at end
19th Aug 2018, 7:59 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Alex “Rusack” Averin where exactly you changed from int to long in your code so that it gave error...? I just changed int damage = 0; to long and it worked with this change... do you mean to say that you changed everywhere as long in place of int...?
19th Aug 2018, 7:31 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
19th Aug 2018, 8:01 PM
Alex “Rusack” Averin
Alex “Rusack” Averin - avatar
+ 1
Alex “Rusack” Averin if you still face any issue in code with above update, please save another code with int as long and share its link to check issue...
19th Aug 2018, 8:01 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
yes, i did change everywhere as long
19th Aug 2018, 7:32 PM
Alex “Rusack” Averin
Alex “Rusack” Averin - avatar