error: `itoa` was not declared in this scope

itoa is not ansi C standard and you should probably avoid it. Here are some roll-your-own implementations if you really want to use it anyway: http://www.strudel.org.uk/itoa/ If you need in memory string formatting, a better option is to use snprintf. Working from your example:

Categories C Tags

lvalue required as increment operand

x++ is the short form of x = x + 1. However, x here is an array and you cannot modify the address of an array. So is the case with your variable y too. Instead of trying to increment arrays, you can declare an integer i and increment that, then access the i‘th index … Read more

Parsing command-line arguments in C

I’m trying to write a program that can compare two files line by line, word by word, or character by character in C. It has to be able to read in command line options -l, -w, -i or –… if the option is -l, it compares the files line by line. if the option is … Read more

GDB no such file or directory

I’m following these lessons from OpenSecurityTraining. I’ve reached the lab part where I’ve to train myself on a CMU Bomb. They provide a x86_64 compiled CMU Bomb that you can find here to train on : CMU Bomb x86-64 originally from a 32-bit bomb from CMU Labs for Computer Systems: A Programmer’s Perspective (CS:APP) 1st … Read more

Swapping 2 Bytes of Integer

Couple of things You can recombine by masking x with a value that is all FF except for bytes m and n You can compute the mask by left shifting 0xFF m times and n times and combining the result and then XOR it with 0xFFFFFFFF FYI when you right shift a signed value, it … Read more

Difference between “while” loop and “do while” loop

The do while loop executes the content of the loop once before checking the condition of the while. Whereas a while loop will check the condition first before executing the content. In this case you are waiting for user input with scanf(), which will never execute in the while loop as wdlen is not initialized … Read more

Question about while(!EOF)

OF is only an integer constant. On most systems it is -1. !-1 is false and while(false) won’t do anything. What you want is to check the return values of scanf. scanf returns the number of successfully read items and eventually EOF.

Categories C

How to Compare 2 Character Arrays [duplicate]

but I read somewhere else that I couldnt do test[i] == test2[i] in C. That would be really painful to compare character-by-character like that. As you want to compare two character arrays (strings) here, you should use strcmp instead: Edit: There is no need to specify the size when you initialise the character arrays. This … Read more

Categories C Tags