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:
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
Be explicit – then the compiler won’t warn that you perhaps made a mistake. or Some day you’ll be glad the compiler told you, people do make that mistake 😉
You haven’t initialized *str_new so it is just copying str_old to some random address. You need to do either this: or You will have to #include <stdlib.h> if you haven’t already when using the malloc function.
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
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
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
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
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.
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