Jump to content

Recommended Posts

Hi Guys,

 

I know this is a forum for PHP and I know this might not be replied to but i am having a problem with another language and i have been gaining knowledge from you guys for ages and i know how quickly everyone responds.

 

I am programming in Processing 1.0 Beta for my Uni and they have asked me to do a simple problem.

 

Its a simple method that outputs numberts from an array...

 

The error i am getting is "This method must return a result of type int".... where am i going wrong??

 

 

  
// Declare my Global Variables  
  int i;
  String OutPutLine = "";
  PFont font;
  String[] Strs;
  int Size;
  int[] Nums;
  int Sum;


//run the first method
void setup() {

  
  font = loadFont("CourierNewPS-BoldMT-24.vlw"); 
  textFont(font);
  background(255, 255, 0);
  fill(0, 0, 0); 
  int[] Nums = { 90, 150, 30 };

}

//run my created method
int Sort(int[] Nums) {
        
    for (i = 0; i < 3; i++) {
     
    return Nums[i];    

    } 
    
}

 

 

What language is this?  Looks like C/C++ but could easily be something else.

 

 

Why not just pass by reference and not have to worry about a return?

 

IE:

 

void someFunction(int[] &var) {
    for(int i = 0; i < 3; ++i) {
        var[i] = i;
    }
}

 

 

That is probably the most pointless method I've ever seen in my life though x.x.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.