In case you were confused by always getting 8 from sizeof(backwards), remember that this will give you the size of a char pointer and not the size of the memory you allocated with malloc (which...
Type: Posts; User: Golf7
In case you were confused by always getting 8 from sizeof(backwards), remember that this will give you the size of a char pointer and not the size of the memory you allocated with malloc (which...
You haven't added a null character after the end of your word in backwards (even though you have allocated space for it) so strlen() doesn't know where it ends.
The standard requires sizeof(char) to be one.
sizeof(backwards) gives you the size of a char pointer, not the length of a string. Strings are terminated with a null character which is what strlen() will be looking for when it calculates the...
amount * 2;
The result of this will be amount multiplied by 2 but it won't be assigned to anything. If you want the value of amount to be multiplied by two then you need to assign the result to...
You have declared integer1, integer2 and sum inside main() and declared three variables with the same names inside addnumbers(). These are not the same.
You are using the number_of_stars variable for both the number of rows you want and the number of spaces to start each line with. In order to have the correct number of spaces at the start of each...
Make that 11, I miscounted the number of characters in your string which is actually 10 characters long itself. With the null character added to the end, the array length will be 11.
char qs [ ] = "textishere";
This will initialize a single dimensional array, with the characters in your string plus a null character to end the string so the length will be 10.
char...
The pointer called root inside insert() is local to the function not the same as the root pointer in main. It will initially point to the address you pass to it but changing it will not change what...
You need both s and t pointing to buffers where your input is stored. One way of doing this is to use arrays as suggested above by vart which I see you have now done.
You haven't initialized s to point to a specific locaion in memory where your input will be written to. Same also goes for t. You them to point to buffers where your input will be written to.
Use the modulus operator (%) to calculate the remainder. If a % b is zero then a is a multiple of b.
Not on Windows (even in 64 bit Windows a long is still 35 bits).
I'm not sure which version of Windows you are compiling for but even in 64 bit Windows a long is still 32 bits. You need to use long long.
See above though, I have noticed I much more serious issue with the code in that I simply don't have enough bits (64 wouldn't be enough but I actually only have 40) available to parse 24 digits into...
Yes, I could do that but I wasn't sure how costly this would be. As for using an unsigned long long, I didn't think I would have been running into the sign bit due to only shifting by 24 bits but...
The smallest possible fraction is 2^(-24) which in decimal is 0.000000059604644775390625. If I attemped to parse this from a string then since there are 24 digits after the decimal point, the...
Hi, I have been writing a fixed point library the would handle fixed point numbers with an 8:24 whole/fraction ratio. This has been working quite well but since I have a 24 bit fractional part, it...
Now I understand what an HDC is, I can see that it will cause a leak in the above code as hdc is local to the function and so not accessible once the function returns. The font in question though is...
I'm curios as to why this
void initialize_font(HFONT hf, HWND hwnd) {
HDC hdc;
TEXTMETRIC tm;
hdc = GetDC(hwnd);
hf = CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Times New...
Here is the revevant part of the code:
int main(void) {
FILE *filein;
filein = fopen("input.txt", "r");
struct Node* head = NULL;
char* input;
while(!feof(filein)) {
input =...
I have been using fgets() to read lines of a file I have and store them in a linked list. This has been working very well but after the last line I seem to end up with "x(smiley face)>" in the list....
I've been working my way through SAMS teach yourself C for Linux programming over the last year and have recently been studying linked lists.
To delete from the middle of a linked list the book...