TOPIC: question: what is the equivalent of "scanf"?
 
Maki
question: what is the equivalent of "scanf"? 2 Weeks ago
good evening i'm new here..still a student and my professor wants me to report about suneido..i already look around and browse the "user's manual" but i can't find the input statement like "scanf" in c...and i notice that suneido is more suitable in database application...so is there a way that i can execute a program like this(it was written in c):

#include <stdio.h>
main()
{
int n[3][4];
int high, low, i, j;
clrscr();
printf("n Enter twelve numbers:nn");
for(i=0;i<3;i++)
for(j=0;j<4;j++)
scanf("%d",&n[i][j]);
high=n[0][0];
/*this loop determines the highest*/
for(i=0;i<3;i++)
for(j=0;j<4;j++)
{
if(high<n[i][j])
high = n[i][j];
}
printf("n highest: %d",high);
getch();
}



PLEASE HELP ME!

..and sorry for my bad english.
 
 
Last Edit: 2010/08/09 17:31 By andrew.
 
 
 
Hi Maki,

Suneido is a GUI program, not console. So there is not really any equivalent to scanf. But you can use the Ask function to prompt for input. This normally returns a string. But Suneido will automatically convert strings to numbers if you use them in arithmetic.

Also, Suneido does not have built-in multi-dimensional arrays. But you can handle this with arrays of arrays (this is similar to Java). And Suneido uses a general purpose data structure - Object - that can be used as an array or as a hash table or dictionary.

Here is one way to write your example in Suneido. You can paste this on the WorkSpace and run it.

 
Code:

n = Object().Set_default(Object())
for (i = 0; i < 3; i++)
    for (j = 0; j < 4; j++)
        n[i][j] = Ask("Enter a number")
high = n[0][0]
for (i = 0; i < 3; i++)
    for (j = 0; j < 4; j++)
        if (high < n[i][j])
            high = n[i][j]
Print(highest: high)


 
 
andrew