[Gambas-user] C Code character manipulation - alternatives
KhurramM
kmsuse at ...626...
Wed May 20 08:00:25 CEST 2009
I am converting the at the end C code to gambas code. But I seem to be
getting nowhere, currently. I am trying. Hope u guide me thru this.
' Gambas module file
' This program demonstrates the relationship
' between a text stream AND character I / O by
' reading characters FROM the keyboard AND THEN
' printing them TO the screen.
PUBLIC SUB Main()
' Declare AND initialize variables.
DIM c, count AS Integer
' The values are initialized at Zero, by above command
' READ , PRINT , AND count characters.
PRINT "Enter characters (ctrl d to quit): "
INPUT c
count += 1
WHILE NOT (c = Eof)
PRINT Chr$(c)
INPUT c
count += 1
WEND
' PRINT the number OF characters printed.
PRINT (count - 1) & " characters printed."
END
' Original C Code:
'/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - * /
'/ * * /
'/ * This program demonstrates the relationship * /
'/ * between a text stream AND character I / O by * /
'/ * reading characters FROM the keyboard AND THEN * /
'/ * printing them TO the screen. * /
'#include < stdio.h >
'#include < stdlib.h >
'main()
'{
' / * Declare AND initialize variables. * /
' Int c, count = 0;
' / * READ , PRINT , AND count characters. * /
' printf("Enter characters (ctrl d to quit): \n");
' c = getchar();
' count + +;
' WHILE (c! = Eof)
' {
' putchar(c);
' c = getchar();
' count + +;
' }
' / * PRINT the number OF characters printed. * /
' printf("%i characters printed. \n", count - 1);
' / * EXIT Program. * /
' RETURN EXIT_SUCCESS;
'}
'/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - * /
'/ / NOTE:
'/ / FOR most OF the unix systems: Eof IS done by: ctrl d
The output in C cdoe is:
Enter characters (ctrl d to quit):
e
e
re
re
tyui
tyui
jhg mnkl
jhg mnkl
19 characters printed.
--
View this message in context: http://www.nabble.com/C-Code-character-manipulation---alternatives-tp23611042p23629486.html
Sent from the gambas-user mailing list archive at Nabble.com.
More information about the User
mailing list