Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about programming within the scope defined in the help center. Closed 14 days ago. Improve this question I don’t know Java at all, but I need this program in C++. Can anyone help me convert it? I know
Tag: c++
How to merge methods with unrelated parameter types into one generic one?
For java/C# There is my code: Can I merge AddTable and AddCup into one method like Add<T> like this: The problem is that there are too many if else. Do you have any better suggestions? Answer Name the methods the same so that they will be overloads of each other: The compiler is smart enough to call the correct method.
Why It is giving me Integer Overflow
Its giving me Integer Overflow both in java and C but when I tried it in Python it gave me right answer . Any reasons ? Answer There are two reasons: Most computer languages use fixed-size integers. Today, that’s often 32 bits. The correct result of your calculation, 2500000025, is a 32-bit number, meaning it’s too big for a signed
Regex to match only 6letter alphanumeric words in a string
I am trying to match the 6 character word that has a combination of ONLY alphanumeric. Example String: I am currently trying regex [a-zA-Z0-9]{6} However, it matches below Output: But, what I need is only combination of alphanumeric. Something like below Desired Output Answer You may use this regex with 2 lookahead conditions: RegEx Demo RegEx Details: b: Word boundary
Can I get the memory address on the data from the static JNI field?
Can I get the memory address on the data from the static JNI field? For example, I have 2 situations: First: Second: The examples are very simple. I just want to get the memory address on the static field data, without using GetStaticObjectField and etc. It is possible? Answer Fields in the JVM have no addresses. There are only references
Socket binding through JNI
I try to open a socket connection on a Linux machine through JNI. If I combine Java_Socket_socket and Java_Socket_bind in same C function, the JNI call works perfectly, but it doesn’t work when I run methods sequentially. This is my code Java code Output: If I create C program from this code, and as regular C program, gcc … &&
JVMTI Invoke toString(); on an Java object from C++ code
So, I was trying to invoke the toString(); method on an object (in this case an enum). This immediately crashed my application. I am assuming that, since the toString(); method isn’t declared directly in the enum but inherited from the Object class (Enum in this case) it is not able to find the method and therefore causes an error. How
Is there a difference in the working of AND operator in JAVA and C? [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 9 months ago. Improve this question
Unexpected behaviour when inserting values into jobjectArray in JNI
Im trying to create a 1D jobjectArray. When printing from inside the loop, “args” array prints correct values but once it is out of the loop, only the last element gets printed repeatedly. This is “args” jobjectArray declaration: This is the loop used to insert values into the jobjectArray: ( rec_msg[] struct array has correct values and there are no
Calling a Java variadic function from C through the JNI
I am currently working on creating some Java bindings for a C library I work on. One of our C-structs has a char buffer that is a file system path. After calling the C function, the buffer is correctly populated. I want to take the buffer and convert it to a java.nio.file.Path member on the Java object. I am having