Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 "Substring index is greater than length of string" (error)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
gayden




PostPosted: Mon Mar 02, 2015 10:17 am   Post subject: "Substring index is greater than length of string" (error)

Task is to write a program that writes a wedge of stars. So, if you input a 7 into get x it'd look like this:
*******
******
*****
****
***
**
*

Here is my code:
code:
var x : int
put "Please enter the initial number of stars: " ..
get x
loop
    for i : 1 .. x
        put "*" (i) ..

    end for
    x := x - 1
    put ""
    exit when (x = 0)
end loop


When I run it I get an error on line 6.

I have no clue what a substring index is.
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Mon Mar 02, 2015 11:24 am   Post subject: RE:"Substring index is greater than length of string" (error)

What is line 6 supposed to do? What does the (i) part mean?
gayden




PostPosted: Mon Mar 02, 2015 3:28 pm   Post subject: Re: RE:"Substring index is greater than length of string" (error)

Insectoid @ Mon Mar 02, 2015 11:24 am wrote:
What is line 6 supposed to do? What does the (i) part mean?

I believe it was Einstein that said something like: "We cannot solve our problems with the same thinking we used when we created them."

I think he's right because looking back at that line, I have no clue what I thought that should do.

Turns out all I had to do was remove the (i)..embarrassing.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: