This is possible, but extremely difficult - for starters, you would need to integrate a garbage collector with your C source. There are a few projects that attempt this, e.g. Toba, but they're unreliable and no longer maintained. Usually you'll find somebody attempting something like this in their Master's thesis, after which it is quickly abandoned.
If you're doing this to try to speed up your program, then don't - Java is already pretty fast compared to natively compiled code (although it tends to use quite a bit more memory), and your translated C code is not going to be able to take full advantage of the C language.
Answer from Zim-Zam O'Pootertoot on Stack OverflowSuggestions needed: Effective Java to C source code converter - Stack Overflow
Java to C++ converter - Software Recommendations Stack Exchange
CONVERT CODE FROM JAVA TO C
Turning C code into Java
Is the Java to Csharp converter free?
Can I also convert C++ back to Java?
Can I also convert C back to Java?
Videos
This is possible, but extremely difficult - for starters, you would need to integrate a garbage collector with your C source. There are a few projects that attempt this, e.g. Toba, but they're unreliable and no longer maintained. Usually you'll find somebody attempting something like this in their Master's thesis, after which it is quickly abandoned.
If you're doing this to try to speed up your program, then don't - Java is already pretty fast compared to natively compiled code (although it tends to use quite a bit more memory), and your translated C code is not going to be able to take full advantage of the C language.
Use Java2C: A translator from Java to C language especially for embedded and fast realtime applications, including a javalike runtime System in C.
http://sourceforge.net/projects/java2c/
Firstly, when it comes to conversion from language 'X' to language 'Y', then no program can beat human intentions/efforts.
For the above case Java to C++ conversion can be done using programs such as TanglibleSoftware. But for some language constructs which are only supported in Java but not in C++, some work around is surely needed.
Consider case: User 'A' hands over his source code to program 'ABCD' for conversion from language 'X' to 'Y', and he assumes to get the result(exact converted code with same behavior) in bare minimal efforts, then user 'A' is calling for a failure.
I will not go into syntactic differences between Java & C++, but if one has a good grasp on programming then for unsupported constructs of language 'X', code can always be written to perform those operations in language 'Y' successfully.
Machines can only understand code, but meaning has to be construed by Humans.
But this may not be constrained if we consider artificial intelligence into this context or some 'xyz' technology in near future.
My answer is based on my experience, I am not affiliated to TanglibleSoftware by any means, the above software worked for me, with some efforts made. It might not have worked for some other users.
Something like this is not really posible, since there is concepts and keywords in Java without equivalents in C++. For example synchronized, package or instanceof canΒ΄t be translated from Java to C++. Even final has not always the same meaning as const.
HI, I am a little bit off topic, but I need your help. I was writing code for a friend in Java that is fairly simple. He does not now that much about programming and is just attending an extra course in University. He needed to do a task so he asked for my help. I said I can help him if the language of use is in Java (asked him twice which language they are using). Long Story short the following code is in Java but I need a translation in c. Do you guys have an idea to approach this? Or is anyone here able to translate it ? I appreciate every tip. Thank u guys.
import java.util.Arrays;
import java.util.Scanner;
public class ascii {
public static void main (String[] args) {
Scanner sc = new Scanner (System.in);
String[] cMtr = new String [3]; // NIMMT 16 ZEICHEN VOM TYP 'char' ENTGEGEN
String matrikelNummerString = "ES3080809";
int matrikelNummerInt = 3080809;
for (int i = 0;i < cMtr.length ; i++) { // LESEN DIE CHARACTERS EIN VOM Char ARRAY - TURN INTO STRING
System.out.println("Enter a string : " + i );
cMtr[i] = sc.next();
}
System.out.println(Arrays.toString(cMtr));
StringBuffer sb = new StringBuffer();
for (int i = 0; i < cMtr.length;i++) {
sb.append(cMtr[i]);
}
String str = sb.toString();
System.out.println(str);
char [] ch = new char [str.length()];
for(int i = 0; i < str.length();i++) {
ch[i] = str.charAt(i);
}
for (char c : ch) {
System.out.print(c);
}
int [] asciiArray = new int [ch.length];
for (int i= 0; i < asciiArray.length;i++) {
asciiArray[i] = (int) ch[i];
}
for (int i =0; i < asciiArray.length;i++) {
asciiArray [i] += matrikelNummerInt ;
asciiArray [i] = asciiArray[i] << 3;
}
for (int i =0; i < asciiArray.length;i++) {
asciiArray [i] = asciiArray[i] << 3;
}
boolean swapped = true;
int j = 0;
int tmp;
while (swapped) {
swapped = false;
j++;
for (int i = 0; i < asciiArray.length - j; i++) {
if (asciiArray[i] < asciiArray[i + 1]) {
tmp = asciiArray[i];
asciiArray[i] = asciiArray[i + 1];
asciiArray[i + 1] = tmp;
swapped = true;
}
}
}
int summe = 0;
for (int i = 0; i <= 2 ; i++) {
summe += asciiArray[i];
}
//String b = cMtr.toString();
System.out.println(Arrays.toString(asciiArray));
System.out.println(summe);
}}