gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Code convert

#136696 - dntd - Fri Aug 03, 2007 10:25 pm

hi how i can convert this code to nds palib dev.

Code:
#include<stdio.h>
#include<math.h>
int a,b,c,D,x;
float R1,R2,R3,Y;
main()
{
printf("Type valor For a\n");
scanf("%d",&a);
printf("Type valor For b\n");
scanf("%d",&b);
printf("Type valor For c\n");
scanf("%d",&c);
printf("Type valor For D\n");
scanf("%d",&D);
R1= a+b;
R2= R1/c;
R3= pow(D,2);
Y= R2+R3;
printf("Result: \n%f",Y);
scanf("%d",x);
}


sorry i'm a noob... :( can anyone helpme?


Last edited by dntd on Sat Aug 04, 2007 1:21 am; edited 1 time in total

#136700 - Jakeohagan - Fri Aug 03, 2007 11:01 pm

whats the fancy letters and numbers do?
does it explode?
_________________
God Speed

#136702 - dntd - Fri Aug 03, 2007 11:07 pm

???

#136703 - NeX - Fri Aug 03, 2007 11:20 pm

Yeah, it'd really help if we knew even the vaguest detail about what it's supposed to do.
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.

#136716 - dntd - Sat Aug 04, 2007 1:21 am

this code is in c++

it requests 4 values
Code:
#include<stdio.h>
#include<math.h>
int a,b,c,D,x;
float R1,R2,R3,Y;
main()
{
printf("Type valor For a\n");
scanf("%d",&a);
printf("Type valor For b\n");
scanf("%d",&b);
printf("Type valor For c\n");
scanf("%d",&c);
printf("Type valor For D\n");
scanf("%d",&D);


then with those values it conducts operations

Code:
R1= a+b;
R2= R1/c;
R3= pow(D,2);
Y= R2+R3;


finally show the result
Code:
printf("Result: \n%f",Y);
scanf("%d",x);
Code:

#136722 - Lick - Sat Aug 04, 2007 2:28 am

scanf() won't work, the DS doesn't have a keyboard. You'll have to make an on-screen numpad of some kind.
_________________
http://licklick.wordpress.com

#136723 - dntd - Sat Aug 04, 2007 3:15 am

how to save a value in a variable?

#136729 - ThousandKnives - Sat Aug 04, 2007 4:38 am

dntd wrote:
how to save a value in a variable?

I'm assuming this statement is an error in translation as you clearly seem to know how to save a value in a variable.

As for storing user input into a variable, Lick is on the money. The NDS has only 12 buttons and a stylus, so you have to toss out any concept of a "keyboard" unless you are prepared to design & program a virtual keyboard on the touch screen. Which could be done, if you're prepared to sink the time into it.

The simpler option is to design a menu-like interface using the up/down or left/right buttons to select an input from a list of possible values. You have to determine what method is appropriate for your application.

#136734 - calcprogrammer1 - Sat Aug 04, 2007 7:17 am

PAlib has a built in virtual keyboard, though I've never used it, but PAlib I don't think has a normal console (you can print text to the screen, but it's not a console with printf() and auto scrolling like libnds has)
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.