|
From: <par...@ya...> - 2002-11-19 20:55:41
|
Hi again!
Is there an equivalent of clrscr() in Dev-C++?
Also can you give me a solution for the counting characters program?
I tried the following but it seems that the printf statement is not
executed.
Thank you!
Paul
#include <stdlib.h>
#include <stdio.h>
void main(void)
{
double nc;
for(nc=0;getchar()!=EOF;nc++)
;
printf("%.0f\n",nc);
system("PAUSE");
}
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
|
|
From: <or...@vp...> - 2002-11-19 21:42:07
|
Hello Paul!
Tuesday, November 19, 2002, 9:55:35 PM, you wrote:
PA> Hi again!
PA> Is there an equivalent of clrscr() in Dev-C++?
I don't know.
PA> Also can you give me a solution for the counting characters program?
PA> I tried the following but it seems that the printf statement is not
PA> executed.
Yes.
I suggest you should write it like this:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int nc; /* use integer instead of double for counting */
for(nc=0;getchar()!=EOF;nc++)
;
printf("\n");
printf("%d\n",nc); /* print as integer */
system("PAUSE");
return 0;
}
Well, the printf() function executes, but it seems that it doesn't
print out anything until you print a newline ('\n') first. I don't
exactly know why this is needed.
If you try the original code (without the first '\n') with a file,
you'll notice that it works. It seems that printf() thinks it is still
at EOF of stdout, until you print '\n'. (which is a foolishness,
because you read from stdin, and stdin reaches EOF!!!) But this only
happens, when you type from the console. When you use a file, it works
normally. (for example: count.exe < file.txt)
--
Best regards,
Oroszi Balázs mailto:or...@vp...
PGP-FP: FB80 8A43 2664 6126 E465 46E2 2546 CFA3 C25B 9F70
finger -l or...@se...
|
|
From: Anders E. <am...@sw...> - 2002-11-19 23:39:05
|
Hello Paul,
Tuesday, November 19, 2002, 9:55:35 PM, you wrote:
PA> Hi again!
PA> Is there an equivalent of clrscr() in Dev-C++?
I assume that you are doing a console application.
There is two ways (.or more.)
Do enough linefeeds to push the last written text above the screen.
e.g. for(int i=0;i<30;i++)printf("\n");
Or use a curses library. PDCurses is a Public Domain library
http://pdcurses.sourceforge.net/
--
Best regards,
Anders mailto:am...@sw...
|
|
From: Carlos d. M. <cg...@wo...> - 2002-11-20 11:44:05
|
For clrscr(). Use conio. The way for use it dependes on the version of
compiler you have. First it was #include <conio.h>, after it lost
everything, and after it was #include <conio.h> and linker -lconio. Or yo=
u
can #include <mingw_conio.h> (check it in the include directory, perhaps
it is conio_mingw.h>.
Anders Eriksson escribi=F3:
> Hello Paul,
>
> Tuesday, November 19, 2002, 9:55:35 PM, you wrote:
>
> PA> Hi again!
> PA> Is there an equivalent of clrscr() in Dev-C++?
> I assume that you are doing a console application.
>
> There is two ways (.or more.)
> Do enough linefeeds to push the last written text above the screen.
> e.g. for(int i=3D0;i<30;i++)printf("\n");
>
> Or use a curses library. PDCurses is a Public Domain library
> http://pdcurses.sourceforge.net/
>
> --
> Best regards,
> Anders mailto:am...@sw...
>
> -------------------------------------------------------
> This sf.net email is sponsored by: To learn the basics of securing
> your web site with SSL, click here to get a FREE TRIAL of a Thawte
> Server Certificate: http://www.gothawte.com/rd524.html
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Per W. <pw...@ia...> - 2002-11-20 00:45:27
|
Are you expecting partial characters, since you are counting with a
floating point variable :-)
/Per W
On Tue, 19 Nov 2002, Paul Ardeleanu wrote:
> Hi again!
> Is there an equivalent of clrscr() in Dev-C++?
> Also can you give me a solution for the counting characters program?
> I tried the following but it seems that the printf statement is not
> executed.
> Thank you!
> Paul
>
>
> #include <stdlib.h>
> #include <stdio.h>
>
> void main(void)
> {
> double nc;
> for(nc=0;getchar()!=EOF;nc++)
> ;
> printf("%.0f\n",nc);
> system("PAUSE");
>
> }
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: To learn the basics of securing
> your web site with SSL, click here to get a FREE TRIAL of a Thawte
> Server Certificate: http://www.gothawte.com/rd524.html
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Brian C. B. <bri...@ho...> - 2002-11-20 01:08:12
|
Hi Paul, > Is there an equivalent of clrscr() in Dev-C++? I believe this URL addresses your problem: http://www.bloodshed.net/faq.html#12. Hope it helps. Sincerely, Brian C. Becker Shall we accept good from God, and not trouble? |
|
From: <or...@vp...> - 2002-11-20 14:57:30
|
Hello Paul!
> #include <stdio.h>
>
> int main(void)
> {
> int nc;
> for(nc=0;getchar()!=EOF;nc++)
> ;
> printf("\n"); /* On Linux this is NOT needed */
> printf("%d\n",nc);
>
> return 0;
> }
Paul wrote:
> Also can you give me a solution for the counting characters program?
> I tried the following but it seems that the printf statement is not
> executed.
Well, I examined your problem further. On my Linux (Debian) YOUR code
works fine (no need for the first '\n').
NOTE that on Linux AND in DevCpp the SAME compiler (gcc) is used, with
the same standard library (just different implementation).
So the problem is with Microslut's Windblows' console stdin/stdout
handling. It is not a suprise that things don't work on Windblows as
you would expect.
--
Best regards,
Oroszi Balázs mailto:or...@vp...
PGP-FP: FB80 8A43 2664 6126 E465 46E2 2546 CFA3 C25B 9F70
finger -l or...@se...
|
|
From: <par...@ya...> - 2002-11-20 15:29:40
|
Thanks guys for all your input! Cheers! Paul --- Oroszi Balázs <or...@vp...> wrote: > Hello Paul! > > Well, I examined your problem further. On my Linux (Debian) YOUR code > works fine (no need for the first '\n'). > > NOTE that on Linux AND in DevCpp the SAME compiler (gcc) is used, with > the same standard library (just different implementation). > > So the problem is with Microslut's Windblows' console stdin/stdout > handling. It is not a suprise that things don't work on Windblows as > you would expect. > > -- > Best regards, > Oroszi Balázs mailto:or...@vp... > > PGP-FP: FB80 8A43 2664 6126 E465 46E2 2546 CFA3 C25B 9F70 > finger -l or...@se... __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com |
|
From: Ioannis V. <no...@ho...> - 2002-11-20 18:49:05
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Paul Ardeleanu
> Sent: Tuesday, November 19, 2002 10:56 PM
> To: dev...@li...
> Subject: [Dev-C++] 2 more questions
>
>
> Hi again!
> Is there an equivalent of clrscr() in Dev-C++?
> Also can you give me a solution for the counting characters program?
> I tried the following but it seems that the printf statement is not
> executed.
> Thank you!
> Paul
>
>
> #include <stdlib.h>
> #include <stdio.h>
>
> void main(void)
int main(void)
> {
> double nc;
> for(nc=0;getchar()!=EOF;nc++)
> ;
> printf("%.0f\n",nc);
printf("%.0lf\n", nc);
> system("PAUSE");
return 0;
> }
What do you mean? The above fixed-to-be-portable code works:
C:\c>temp <temp.c
182
Press any key to continue . . .
C:\c>
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: <par...@ya...> - 2002-11-21 18:40:04
|
Why are you all so keen in returning a value at the end of main? Paul --- Ioannis Vranos <no...@ho...> wrote: > int main(void) ... > return 0; > > > } __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com |
|
From: Ioannis V. <no...@ho...> - 2002-11-21 20:15:42
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Paul Ardeleanu > Sent: Thursday, November 21, 2002 8:40 PM > To: Dev-C++ Mailing List > Subject: RE: [Dev-C++] 2 more questions > > > Why are you all so keen in returning a value at the end of main? It is required in C90. Not required in C++98 and C99 (=if you do not return anything, a value indicating success is returned implicitly). Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL: http://run.to/noicys |
|
From: Luigi S. <gi...@li...> - 2002-11-23 13:11:44
|
On Thu, Nov 21, 2002 at 06:39:59PM +0000, Paul Ardeleanu wrote: > Why are you all so keen in returning a value at the end of main? > > Paul Besides what Ioannis has already said, another good reason to have a program return some value is to ... use the value! :) For instance, I remember that the (now, or soon to be, obsolete) command.com shell allowed to write some script file like the following rv_test.bat ----------- rem use return value of "foo" to choose a label foo if errorlevel 2 goto label2 if errorlevel 1 goto label1 :else echo program "foo" returned 0 (success) goto end :label1 echo program "foo" returned 1 goto end :label2 echo program "foo" returned a value greater or equal to 2 goto end :end -------- I can't test the above right now (running bash :), but it should work -- >> gisan >> Q: Heard about the <ethnic> who couldn't spell? A: He spent the night in a warehouse. |
|
From: Ioannis V. <no...@ho...> - 2002-11-23 22:18:36
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Luigi Santillo > Sent: Friday, November 22, 2002 4:35 PM > To: Dev-C++ Mailing List > Subject: Re: [Dev-C++] 2 more questions > > > On Thu, Nov 21, 2002 at 06:39:59PM +0000, Paul Ardeleanu wrote: > > Why are you all so keen in returning a value at the end of main? > > > > Paul > > Besides what Ioannis has already said, another good reason to > have a program return some value is to ... use the value! :) > > For instance, I remember that the (now, or soon to be, obsolete) > command.com shell allowed to write some script file like the > following > > rv_test.bat > ----------- > rem use return value of "foo" to choose a label > foo > > if errorlevel 2 goto label2 > if errorlevel 1 goto label1 > :else > echo program "foo" returned 0 (success) > goto end > > > :label1 > echo program "foo" returned 1 > goto end > > :label2 > echo program "foo" returned a value greater or equal to 2 > goto end > > :end > -------- Yep, errorlevels. I think Win & Linux have that too. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ho...> - 2002-11-20 18:49:32
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Paul Ardeleanu
> Sent: Tuesday, November 19, 2002 10:56 PM
> To: dev...@li...
> Subject: [Dev-C++] 2 more questions
>
>
> Hi again!
> Is there an equivalent of clrscr() in Dev-C++?
system("cls");
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|