My code:
Primitive<uint64_t> full = 0xBBBBBBBBCCCCCCCC;
Primitive<uint64_t> first = 0x0000000000000000;
first = (full & 0xFFFFFFFE00000000);
std::cout << "FIRST: " << first << std::endl;
...
Type: Posts; User: mondaytofriday
My code:
Primitive<uint64_t> full = 0xBBBBBBBBCCCCCCCC;
Primitive<uint64_t> first = 0x0000000000000000;
first = (full & 0xFFFFFFFE00000000);
std::cout << "FIRST: " << first << std::endl;
...
thanks!
Hello,
I have a 64-bit uint64_t number:
Primitive<uint64_t> b = 0xCCCCCCCC00000000;
I need to save the first 31 (most important) bits - 7FFFFFFE.
I found this solution in the Internet:
I think I got it sorted now :) thanks anyway.
I do use printf in other places, just prefer std::cout for temporary logging as I used to use it in my happy C++ days :)
Well I can use things like std::cout in my code for now, but will need to remove them later for the final build, as the final product will need to run on a C-only system.
What would I do then in this case:
char* endText;
endText = strstr(*objectData2, " 5000");
I don't know how long endText would be, but I need to append '\0' to the end of it. I was going to...
this is C with some C++ functionality...
oh! gotcha :) thanks
oh right.... isn't appending a null character the same as strcat-int an empty string?
oh... didn't realise I had to do it as I was using all 6 chars in it, I thought all the rubbish in the startText would be overwritten...
but yes, this sorted the problem:
for (int i = 0; i <...
Could someone explain to me what is going on here? Why does this code:
char[6] startText;
char data[] = "1.1\nWord\nWord\n0-5\n\0";
char* dataPtr = data;
char** objectData2 = &dataPtr;
Oh! I didn't realise I could do it this way: std::sscanf(*objectData, "%*f %*s %*s %d - %d", &num1, &num2);
This seemed to work!
right... I've been reading about sscanf and sprintf, and it does look like it's what I need, but at the moment I am getting strange results.
here is an example:
*objectData is:
...
Thanks, ill give it a try... But so far I find c string functions really difficult - always give weird results and it takes ages to recompile and retest in my environment
Problem:
I have a pointer to a pointer to a C string:
char **objectData;
In this string there are some numbers with a dash between them, for example, "5-10". I need to read these numbers in...
Yes, thanks :)
Sorry, completely forgot about strcpy :) Works!
Basically, I have a pointer to a C string:
char **objectData
and a C string:
char temp[350];
Sorry ignore the /r problem - I was logging incorrectly. /r exist in the original data as well.
Meanwhile, I think I found the problem.
I printed out the original objectData and the new objectData character by character. The original data contains new line characters. They also exist in the...
Thanks. I'll explore this.
Yes, I do :) thank you
Maybe I should append a null character then? I'll try this as well.
I started writing my own for loop to read through the data, and am getting a silly problem - how do I access the characters??...
Ah, strlen. I'll try this, thanks.
I'm inserting the text somewhere in the middle and only once in the function. But I guess doing it manually might be an option as I do get some rubbish in the...