Copy a string: Difference between revisions
Content deleted Content added
Added solution for Action! |
mNo edit summary |
||
Line 2,502: | Line 2,502: | ||
<lang basic>10 LET a$ = "Hello": REM a$ is the original string |
<lang basic>10 LET a$ = "Hello": REM a$ is the original string |
||
20 LET b$ = a$: REM b$ is the copy</lang> |
20 LET b$ = a$: REM b$ is the copy</lang> |
||
=={{header|Amazing Hopper}}== |
|||
Version 1: |
|||
Assign variable "s" to variable "b". |
|||
<lang Hopper> |
|||
#include <hopper.h> |
|||
main: |
|||
s = "string to copy" |
|||
t = s |
|||
{s,"\n",t}println |
|||
exit(0) |
|||
</lang> |
|||
Output: |
|||
string to copy |
|||
string to copy |
|||
Version 2: |
|||
Soft copy to variable (CPY). |
|||
<lang Hopper> |
|||
#include <hopper.h> |
|||
main: |
|||
s="" |
|||
{"1:","string to copy"},cpy(s),println |
|||
{"2:",s}println |
|||
exit(0) |
|||
</lang> |
|||
Output: |
|||
1:string to copy |
|||
2:string to copy |
|||
Version 3: |
|||
From stack to var: hard copy (move, MOV). |
|||
<lang Hopper> |
|||
#include <hopper.h> |
|||
main: |
|||
s="" |
|||
{"string to copy"},mov(s) |
|||
{s}println |
|||
exit(0) |
|||
</lang> |
|||
Output: |
|||
string to copy |