473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

hOW TO CONVERT C++ TO JAVA CODE?

Hi I'm making a flames game but what i'm using is processing and i think processing reads java code so does anyone of you knwo how to convert c++ code to java code? The code is below:
or you may look at it in the text file


‪#‎include‬<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node
{
char cha;
struct node *next;
};
void push(struct node** head_ref, char new_data)
{
struct node* new_node =(struct node*) malloc(sizeof(struct node));
new_node->cha = new_data;
new_node->next = (*head_ref);
(*head_ref)= new_node;
}
struct node* deleteit(struct node *temp,int n)
{
n=n-1;
int count=1;
struct node *p,*q;
while(count<n)
{
temp=temp->next;
count++;
}
p = temp->next->next;
q=temp->next;
temp->next=p;
free(q);
return p;
}

int absolute(int x,int y)
{
if(y>x)
return y-x;
else
return x-y;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int c[30],d[30],m,x,n=0,i;
char a[20007],b[20007];
struct node *head=NULL;
struct node *tem;
struct node *temp;
scanf("%s",a);
scanf("%s",b);
x=strlen(a);
m=strlen(b);
for(i=0;i<28;i++)
{
c[i]=0;
d[i]=0;
}
for(i=0;i<x;i++)
{
if(a[i]>='a'&&a[i]<='z')
c[a[i]-'a']++;
else
c[a[i]-'A']++;
}
for(i=0;i<m;i++)
{
if(b[i]>='a'&&b[i]<='z')
d[b[i]-'a']++;
else
d[b[i]-'A']++;
}
for(i=0;i<28;i++)
n=n+absolute(c[i],d[i]);
push(&head,'s');
push(&head,'e');
push(&head,'m');
push(&head,'a');
push(&head,'l');
push(&head,'f');
tem=head;
while(tem->next!=NULL)
{
tem=tem->next;
}
tem->next=head;
if(n==0||n==1)
printf("SISTER\n");
else
{
temp=deleteit(head,n);
temp=deleteit(temp,n);
temp=deleteit(temp,n);
temp=deleteit(temp,n);
temp=deleteit(temp,n);
if(temp->cha=='f')
printf("FRIENDS\n");
if(temp->cha=='l')
printf("LOVE\n");
if(temp->cha=='a')
printf("ADORE\n");
if(temp->cha=='m')
printf("MARRIAGE\n");
if(temp->cha=='e')
printf("ENEMIES\n");
if(temp->cha=='s')
printf("SISTER\n");
}
}
return 0;
}
Attached Files
File Type: txt flamescode.txt (1.7 KB, 387 views)
Oct 3 '14 #1
2 2874
weaknessforcats
9,208 Expert Mod 8TB
There are various C++ to Java converters but none I know about are 100% accurate. You will need to fuss with the converted code t get the program working.

The other thing you can do is just call the C++ code Java and start fixing errors. This will be more work but you will better control over the changes.
Oct 3 '14 #2
Hallo, you could use this program:
http://sourceforge.net/projects/btoc/?source=directory
Aug 5 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Ravi | last post by:
Do we have anything that could convert C++ code to java code? To what extent are such tools reliable? TIA. -- main(){char s="sbwjAeftqbnnfe/dpn!ps!CSbwjACjhgppu/dpn"; int...
7
by: cs_hart | last post by:
I have an application in Java that I would like to port to c++ to integrate with existing c++ app. is anyone aware of any tools to help? I found microsft has a java->csharp convert, but the java...
0
by: Chua Wen Ching | last post by:
Hi there, I had downloaded the Java Language Conversion Assistant 2.0 from http://msdn.microsoft.com/vstudio/downloads/tools/jlca/. I had installed it and it was suppose to integrate to...
2
by: BuddyWork | last post by:
Are anyone aware of any conversion tool out there which can convert the java code to C#.
2
by: Barney | last post by:
I have to convert a Java app to .NET, i found and used the conversion tool which converts java to C#, but it only converted about 10% of it, how hard would it be to re-write the java app and keep...
0
by: florian.grimps | last post by:
Hello. I try to convert a bigger piece of java to c#. Initially I use the JLCA 3 form VS 2005, but the results are far from being perfect, so I had to convert much code on my own. I have big...
4
by: waterfall | last post by:
can anyone convert java code to C#?
0
by: Hotice | last post by:
Hello all, I want to create a web application for sending booking requests to DHL. I already found a toolkit (http://xmlshippingtest.dhl-usa.com/toolkit/index.html) that uses XML files to send the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.