Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,712 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,396 people online right now. Registration is fast and FREE... Join Now!




from C++ to C

 
Reply to this topicStart new topic

from C++ to C, how to convert this code

duygugvn
post 21 Dec, 2005 - 11:59 PM
Post #1


New D.I.C Head

*
Joined: 31 Oct, 2005
Posts: 36


My Contributions


......
........
//int selected[50]={0};
.......
......
......

{

for(int i=0; i<24; i++){
arr[row][i]=rand()%2;
cout<<arr[row][i];
}

.............
............
................
..............





cout<<"count: "<<count<<endl;
int fit=(term1-1)*(term1-1)+(term2-3)*(term2-3)+(term3-13)*(term3-13);
//cout<<term1<<" "<<term2<<" "<<term3<<" "<<fit<<"\n";


these some pieces of my code... I do not know how to convert to C.especialy I could not understand //these slash:)
I do not have enough time last two days
help me!!!
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 22 Dec, 2005 - 07:14 AM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,163



Thanked 32 times

Dream Kudos: 25
My Contributions


The double slashes indicate a single line comment. If you see them on a line, that means everything following the slashes on that line is commented out. As for conversion to C, very little needs to be changed. Making the assumption that the arrays contains integers:
CODE

int i;
for(i=0; i<24; i++){
arr[row][i]=rand()%2;
printf("%d",arr[row][i]);
}

and
CODE

int fit;
printf("count: %d\n",count);
fit=(term1-1)*(term1-1)+(term2-3)*(term2-3)+(term3-13)*(term3-13);
/*printf("%d %d %d\n",term1,term2,term3);*/

This makes the assumption that all variables are integers. You can modify based on variable type.
User is offlineProfile CardPM

Go to the top of the page

duygugvn
post 22 Dec, 2005 - 03:08 PM
Post #3


New D.I.C Head

*
Joined: 31 Oct, 2005
Posts: 36


My Contributions


I have to ask this function definition....
I could not understand where it is used (BOOL)????....


bool collided(int arr[50][24], int row)

what is the meaning of bool is it related to C or C++???

if it is used for C++,what ı used for C which gives the same meaning
User is offlineProfile CardPM

Go to the top of the page

Mrafcho001
post 22 Dec, 2005 - 03:54 PM
Post #4


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


bool is like any other storage type (int, char, double, float) except it is only 1 bit big. Can only store 1 or 0. Thats why its boolean storage type.

bool functions return true or false, nothing else.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 09:39AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month