MRT
Do you know how strlen implemented?
yes, but why first read get me a currect length ?
Vlad
It remembers it's length
MRT
It remembers it's length
ok,thanks, i worked on byte array
Vala
Hii
Vala
What is html
Anonymous
What is html
https://letmegooglethat.com/?q=What+is+html%3F
Haile
What is html
its the best language to Hack NASA
Haile
/get cbook
armandofsanchez
armandofsanchez
string::c_str - C++ Reference http://www.cplusplus.com/reference/string/string/c_str/
Sergey
Good afternoon, who can help me with this? I have a Button: HWND hButtonTest = CreateWindowEx (0, _T ("BUTTON"), _T ("Test"), WS_CHILD | WS_VISIBLE, 0, 0, 120, 40, hMyWindow, (HMENU) IDC_BUTTON_TEST, 0, 0); and I have a method: void CExampleDlg :: OnBtnClickedBtnTakePhoto () { // Source Code } My task is this: if you click on a button, then follow this method. I can't do it, good people can you help me with this?
Vlad
Try with *x=strcpy(...)
You must allocate the memory first
Vlad
So for it to make more sense it should be strdup()
Diego
It's mostly programmed in Java
Diego
If you want to make Android apps instead then my automated reply is Xamarin & .NET
Vala
Tnx
Tamah
C
Bojan_Krdemn
hi! i have a problem, when making a recursive call and passing Point pt the value of pt doesn't change even though i call method foo (adjustedpoint(start, dir)) - demanding it to change over iterations
Prince Of Persia
Anyone have any link to a group about linux??
Thailand import
#include <math.h> #include <swiftnav/constants.h> #include <swiftnav/coord_system.h> #include <swiftnav/float_equality.h> #include <swiftnav/linear_algebra.h> #include <swiftnav/logging.h> void llhrad2deg(const double llh_rad[3], double llh_deg[3]) { llh_deg[0] = llh_rad[0] * R2D; llh_deg[1] = llh_rad[1] * R2D; llh_deg[2] = llh_rad[2]; } void llhdeg2rad(const double llh_deg[3], double llh_rad[3]) { llh_rad[0] = llh_deg[0] * D2R; llh_rad[1] = llh_deg[1] * D2R; llh_rad[2] = llh_deg[2]; } void wgsllh2ecef(const double llh[3], double ecef[3]) { double d = WGS84_E * sin(llh[0]); double N = WGS84_A / sqrt(1. - d * d); ecef[0] = (N + llh[2]) * cos(llh[0]) * cos(llh[1]); ecef[1] = (N + llh[2]) * cos(llh[0]) * sin(llh[1]); ecef[2] = ((1 - WGS84_E * WGS84_E) * N + llh[2]) * sin(llh[0]); } void wgsecef2llh(const double ecef[3], double llh[3]) { /* Distance from polar axis. */ const double p = sqrt(ecef[0] * ecef[0] + ecef[1] * ecef[1]); /* Compute longitude first, this can be done exactly. */ if (!double_equal(p, 0)) { llh[1] = atan2(ecef[1], ecef[0]); } else { llh[1] = 0; } if (p < WGS84_A * 1e-16) { llh[0] = copysign(M_PI_2, ecef[2]); llh[2] = fabs(ecef[2]) - WGS84_B; return; } /* Caluclate some other constants as defined in the Fukushima paper. */ const double P = p / WGS84_A; const double e_c = sqrt(1. - WGS84_E * WGS84_E); const double Z = fabs(ecef[2]) * e_c / WGS84_A; /* Initial values for S and C correspond to a zero height solution. */ double S = Z; double C = e_c * P; /* Neither S nor C can be negative on the first iteration so * starting prev = -1 will not cause and early exit. */ double prev_C = -1; double prev_S = -1; double A_n, B_n, D_n, F_n; /* Iterate a maximum of 10 times. This should be way more than enough for all * sane inputs */ for (int i = 0; i < 10; i++) { /* Calculate some intermediate variables used in the update step based on * the current state. */ A_n = sqrt(S * S + C * C); D_n = Z * A_n * A_n * A_n + WGS84_E * WGS84_E * S * S * S; F_n = P * A_n * A_n * A_n - WGS84_E * WGS84_E * C * C * C; B_n = 1.5 * WGS84_E * S * C * C * (A_n * (P * S - Z * C) - WGS84_E * S * C); /* Update step. */ S = D_n * F_n - B_n * S; C = F_n * F_n - B_n * C; if (S > C) { C = C / S; S = 1; } else { S = S / C; C = 1; } /* Check for convergence and exit early if we have converged. */ if (fabs(S - prev_S) < 1e-16 && fabs(C - prev_C) < 1e-16) { break; } prev_S = S; prev_C = C; } A_n = sqrt(S * S + C * C); llh[0] = copysign(1.0, ecef[2]) * atan(S / (e_c * C)); llh[2] = (p * e_c * C + fabs(ecef[2]) * S - WGS84_A * e_c * A_n) / sqrt(e_c * e_c * C * C + S * S); }
Vlad
Only god and your compiler knows
Thailand import
[Error] swiftnav/constants.h: No such file or directory compilation terminated.
Vlad
[Error] swiftnav/constants.h: No such file or directory compilation terminated.
That means that either file doesn't exist or it's not in your include path
Vlad
Also consider using #include "header.h" instead
Vlad
<> will do lookup in the compiler include folder
Mihai
#include <math.h> #include <swiftnav/constants.h> #include <swiftnav/coord_system.h> #include <swiftnav/float_equality.h> #include <swiftnav/linear_algebra.h> #include <swiftnav/logging.h> void llhrad2deg(const double llh_rad[3], double llh_deg[3]) { llh_deg[0] = llh_rad[0] * R2D; llh_deg[1] = llh_rad[1] * R2D; llh_deg[2] = llh_rad[2]; } void llhdeg2rad(const double llh_deg[3], double llh_rad[3]) { llh_rad[0] = llh_deg[0] * D2R; llh_rad[1] = llh_deg[1] * D2R; llh_rad[2] = llh_deg[2]; } void wgsllh2ecef(const double llh[3], double ecef[3]) { double d = WGS84_E * sin(llh[0]); double N = WGS84_A / sqrt(1. - d * d); ecef[0] = (N + llh[2]) * cos(llh[0]) * cos(llh[1]); ecef[1] = (N + llh[2]) * cos(llh[0]) * sin(llh[1]); ecef[2] = ((1 - WGS84_E * WGS84_E) * N + llh[2]) * sin(llh[0]); } void wgsecef2llh(const double ecef[3], double llh[3]) { /* Distance from polar axis. */ const double p = sqrt(ecef[0] * ecef[0] + ecef[1] * ecef[1]); /* Compute longitude first, this can be done exactly. */ if (!double_equal(p, 0)) { llh[1] = atan2(ecef[1], ecef[0]); } else { llh[1] = 0; } if (p < WGS84_A * 1e-16) { llh[0] = copysign(M_PI_2, ecef[2]); llh[2] = fabs(ecef[2]) - WGS84_B; return; } /* Caluclate some other constants as defined in the Fukushima paper. */ const double P = p / WGS84_A; const double e_c = sqrt(1. - WGS84_E * WGS84_E); const double Z = fabs(ecef[2]) * e_c / WGS84_A; /* Initial values for S and C correspond to a zero height solution. */ double S = Z; double C = e_c * P; /* Neither S nor C can be negative on the first iteration so * starting prev = -1 will not cause and early exit. */ double prev_C = -1; double prev_S = -1; double A_n, B_n, D_n, F_n; /* Iterate a maximum of 10 times. This should be way more than enough for all * sane inputs */ for (int i = 0; i < 10; i++) { /* Calculate some intermediate variables used in the update step based on * the current state. */ A_n = sqrt(S * S + C * C); D_n = Z * A_n * A_n * A_n + WGS84_E * WGS84_E * S * S * S; F_n = P * A_n * A_n * A_n - WGS84_E * WGS84_E * C * C * C; B_n = 1.5 * WGS84_E * S * C * C * (A_n * (P * S - Z * C) - WGS84_E * S * C); /* Update step. */ S = D_n * F_n - B_n * S; C = F_n * F_n - B_n * C; if (S > C) { C = C / S; S = 1; } else { S = S / C; C = 1; } /* Check for convergence and exit early if we have converged. */ if (fabs(S - prev_S) < 1e-16 && fabs(C - prev_C) < 1e-16) { break; } prev_S = S; prev_C = C; } A_n = sqrt(S * S + C * C); llh[0] = copysign(1.0, ecef[2]) * atan(S / (e_c * C)); llh[2] = (p * e_c * C + fabs(ecef[2]) * S - WGS84_A * e_c * A_n) / sqrt(e_c * e_c * C * C + S * S); }
Share your code through one of these links: • https://linkode.org • https://dpaste.org • https://pastebin.com • https://hastebin.com
Thailand import
🤔🤔
Anonymous
For what
For posting long code snippets.
Thailand import
I see, alright alright 😁😂
MᏫᎻᎯᎷᎷᎬᎠ
Is it okay to overuse lambdas? There is a code I met in https://lefticus.gitbooks.io/cpp-best-practices/content/08-Considering_Performance.html It suggests: // Bad Idea std::string somevalue; if (caseA) { somevalue = "Value A"; } else if(caseB) { somevalue = "Value B"; } else { somevalue = "Value C"; } ——- // Better Idea const std::string somevalue = [&](){ if (caseA) { return "Value A"; } else if (caseB) { return "Value B"; } else { return "Value C"; } }();
Vlad
That is because it will be initialized in place
MᏫᎻᎯᎷᎷᎬᎠ
Second one is just slightly better
even in performance term? why?
Vlad
even in performance term? why?
No need to assign empty state
Vlad
Copy ellision and all of that
Vlad
That is because it will be initialized in place
Semantically tho it's the same really
MᏫᎻᎯᎷᎷᎬᎠ
Hmmmm yeah
MᏫᎻᎯᎷᎷᎬᎠ
damn there are a lot to think about hahaha
Anonymous
Get ide
klimi
Get ide
/get ide
Anonymous
Get cbook
Pritam
Please give me a solution
Pritam
What is dynamic memory allocation
Pritam
?
MrILL
What is dynamic memory allocation
some kind of computer magic
Pritam
I can't understand
Chinepun💛
What is dynamic memory allocation
I think it is when u ask your Operating system for memory
Diego
What is dynamic memory allocation
It's when you use new or malloc
Diego
There are three types of memory in C++: The Stack, Static Memory, and the Heap
Diego
I'll assume that you already know what the stack is
Diego
Static Memory is a region in memory where all objects tied to global variables are allocated, and are expected to leave through the lifetime of the app
Diego
Basically any variable you declare outside a class or function is in static memory
Diego
Then there's the heap, where all dynamic allocations are made Whenever you use new you're creating an object in the heap, dynamically allocating (allocating while the program is running) and receiving back a pointer to it
Diego
You then store that pointer in a pointer variable myclass* and dereference it to use it
a Semicolon
#include <stdio.h> #define RUN int str_len(char *); // Calculating the length of String through Pointer. char *str_reverse(char *); // Reversing a String through Pointer. #ifdef RUN int main() { char *str = "Computer"; printf("Length of the String is: %d\n", str_len(str)); printf("Reversed String is: %s\n", str_reverse(str)); return 0; } int str_len(char *ptr) { int i; for (i=0; *(ptr+i)!='\0'; i++); return i; } char *str_reverse(char *ptr) { int len; printf("%d", len); for (len=0; *(ptr + len) != '\0'; len++); for (int i = 0; i < len/2; i++) { // Swapping char temp = *(ptr+i); *(ptr+i) = *(ptr+len-1-i); *(ptr+len-1-i) = temp; } return (ptr); } #endif // RUN
Diego
You then store that pointer in a pointer variable myclass* and dereference it to use it
Dereferencing is scoping to where the object being pointed to actually is You can do that with the dereference operator *myvariable.myfield or myvariable->myfield
Vlad
Pritam
In Programming language, how much the importance of math?
Diego
Not exactly constructor isnt called
Ah, true You can also use this method in C++ (malloc(sizeof)) if you don't want new to call the constructor
Vlad
Not in C ofc
Vlad
In Programming language, how much the importance of math?
If your domain requires math you'd use it in programming for that domain as well
Vlad
As simple as that
a Semicolon
I saw the problem is happening on *(ptr+i) = *(ptr+len-1-i);