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.


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to