Skip to main content
2 votes
Accepted

I have written this swap code but it is not compiling, Where's the bug

You don't need to specify the return type of your function when you call it, only when you declare/define it. So you've declared the function right, like this: void swap (int* a,int* b) But when you ...
Yuri Laguardia's user avatar
2 votes
Accepted

Why function free() is not working here

int temp is not dynamically allocated, you only free() dynamically allocated or malloced memory. int temp, which is static, gets freed from memory as soon as you exit its scope.
kluvin's user avatar
  • 1,223
1 vote
Accepted

How to swap elements in "struct" data type?

It's not really clear what you mean by "swapping elements". I can't see why you'd change one element in a struct, but I can see how you might want to swap entire structs. Say that you have ...
Cliff B's user avatar
  • 69.2k
1 vote
Accepted

Pset3 (Game of Fifteen): The tiles won't swap... ("Illegal move")

You use 0-based indexing (the C standard) in some places (move, won), but 1-based indexing in others (init, draw). You use a strange variable blank. This variable is initially of undefined value (...
Blauelf's user avatar
  • 21k

Only top scored, non community-wiki answers of a minimum length are eligible