Register | Login
Forum Index > Samples > string samples
Author Message
Pages: 1
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[30] string samples - posted: 2011-05-12 15:08:35
In this thread i will post several different string examples over time, the first one is a simple console that will output "test"

the basics are, you allocate heap space for the string "TEST" it is converted to lowercase then output to the console

compiled with ziron 1.1.12.2

Code:
program WIN32CUI 'Sample';

//include simple memory manager - required for new, delete
#include 'smm32.zir';

//include console helpers for writing to the console
#include 'console.zir';

//declare a string pointer and allocate 5 bytes on the heap
char* mystr = new 5;

//copy the string TEST into 4 of the 5 allocated bytes, the last is a null char
strlcpy(mystr, 'TEST', 4);

//call the RTL function strLower to make the "TEST" to lowercase "test"
mystr = strLower(mystr);

//output the string, which will output "test"
WriteLn(mystr);

//deallocate the storage
delete mystr;

//sleep for 1 second to view the output before closing
Sleep(1000);

//exit the process
ExitProcess(0);


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 4 user(s) online. 0 member(s) and 4 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd