Why do I get clang: error: linker command failed with exit code 1?

Why do I get clang: error: linker command failed with exit code 1? You just declared the function. There is not any definition in code. At the time of linking process , compiler(here clang) cannot link power function to its definition so linker throws the error in this kind of situation. If you define Then linker can … Read more

Categories C Tags

Why do I get an assertion failure?

My guess is that the file is failing to open, and you’re still passing it to fgets. Your if(rd==NULL) doesn’t stop execution of the fgets if it’s null, it just prints out a message and continues with execution. Some very basic errorr handling:

What is char ** in C?

Possible Duplicate:What is double star? I am fairly new to C, and have come across this statement I have a pretty good idea of what typedef does, but I have never seen char** before. I know that char* is a char array or similiar to a string. Im not sure if char** is a 2d … Read more

Categories C Tags

error: expected declaration or statement at end of input in c

Normally that error occurs when a } was missed somewhere in the code, for example: would fail with this error due to the missing } at the end of the function. The code you posted doesn’t have this error, so it is likely coming from some other part of your source.

Categories C Tags

Try catch statements in C

C itself doesn’t support exceptions but you can simulate them to a degree with setjmp and longjmp calls. This website has a nice tutorial on how to simulate exceptions with setjmp and longjmp http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html

Categories C Tags

How to replicate vector in c?

Vector and list aren’t conceptually tied to C++. Similar structures can be implemented in C, just the syntax (and error handling) would look different. For example LodePNG implements a dynamic array with functionality very similar to that of std::vector. A sample usage looks like: As can be seen the usage is somewhat verbose and the code needs to be … Read more

Categories C Tags

No Symbol Table using GDB on Compiled Programs

The No symbol table loaded message you are getting is misleading: all GDB is telling you is that your binary does not have any debugging info in it. Usually this is solved by rebuilding the binary with -g flag, but since you are given an already compiled and linked file, you can’t do that. Without debug info, certain commands, such as list, break … Read more

Warning comparison between pointer and integer in C language

I’m assuming that this “type_of_assessment” variable is of char * (pointer to a character) so when you are comparing a character to a char pointer it throws this error. This char * variable stores the address of the actual value stored so you have to de reference it first. Try this in your if condition:

Categories C Tags