dev-cpp-users Mailing List for Dev-C++ (Page 483)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
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: Brenden T. <br...@rc...> - 2002-11-20 00:53:00
|
Oroszi Balázs wrote: >Well, first of all the compiler has nothing to do with the DevCpp >developers. > Duoh! I keep forgetin' that. >As you could read, it is DEPRECATED. GCC 3.2 > Good, so the GCC guys know about it, and it's being worked on. Problem solved, I'd say. TTFN! |
|
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: <or...@vp...> - 2002-11-20 00:34:32
|
Hello dev-cpp-users! Again, shortly: How Can I Tell DevCpp not to pass the -I and -L flags to the compiler globally (I need no include and library paths). Please help me. -- Best regards, Oroszi 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: <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: <or...@vp...> - 2002-11-19 21:15:52
|
Hi problem hunters! Tuesday, November 19, 2002, 7:37:32 PM, Brenden wrote: BT> Newlines are illegal in string constants, according to K&R. It's a bug, BT> you should reported to the DevCpp folks. Well, first of all the compiler has nothing to do with the DevCpp developers. The compiler that DevCpp uses, is the Minimalist GNU for Windows (MinGW). It uses the GNU Compiler Collection (gcc) for compiling. Take a look at http://www.mingw.org for details. >>main () >>{ >> printf("hello, world >> \n >> >> >> "); >> system("PAUSE"); >>} The reason why this works, is this: " Using the GNU Compiler Collection: String Literals with Embedded Newlines As an extension, GNU CPP permits string literals to cross multiple lines without escaping the embedded newlines. Each embedded newline is replaced with a single `\n' character in the resulting string literal, regardless of what form the newline took originally. CPP currently allows such strings in directives as well (other than the `#include' family). This is deprecated and will eventually be removed. " As you could read, it is DEPRECATED. GCC 3.2 (what I have installed) gives the following warning for the program (older ones don't): warning: multi-line string literals are deprecated Look at: http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/ and search for "String Literals with Embedded Newlines". -- 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-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 20:32:53
|
Hello j b!
Jörgen wrote:
> Make sure to test that
> s->firstptr != NULL
> otherwise the right-hand-side of the statement
> s->firstptr=s->firstptr->next;
> would be
> NULL->next
> and that is ofcourse wrong
Oh, yes, I forgot that, of course you need to check whether it is
NULL, or not, sorry %) But despite that, I still recommend to use the
C++ built-in (standard library) lists. Or if you don't know how to use
them, then try this code for pop:
node *pop(stack *s){
node *nptr; /* Only a pointer */
nptr = s->firstptr;
if (s->firstptr != NULL) s->firstptr = s->firstptr->next;
return nptr;
}
pop() will return NULL, if there are no elements. And you should
delete the node from "outside", when you "popped" it out and done all
calculations with it, so that you won't trash the memory.
--
Best regards,
Oroszi Balázs mailto:or...@vp...
P.S.: Correct the code, if it is wrong, please!
PGP-FP: FB80 8A43 2664 6126 E465 46E2 2546 CFA3 C25B 9F70
finger -l or...@se...
|
|
From: <par...@ya...> - 2002-11-19 20:31:26
|
Ioannis,
I was talking about printf on multiple lines. Kala? :)
Paul
--- Ioannis Vranos <no...@ho...> wrote: > > -----Original
Message-----
> > From: dev...@li...
> > [mailto:dev...@li...] On Behalf
> > Of Paul Ardeleanu
> > Sent: Tuesday, November 19, 2002 1:47 PM
> > To: dev...@li...
> > Subject: [Dev-C++] A simple problem
> >
> >
> > Can Anyone tell me why this code WORKS FINE in DevC++?
> > ANSI C says that it any Ansi compiler should give you an
> > error (see K&R
> > book).
> > Thank you very much!
> > Paul
> >
> > -----------------------------------------------------------
> > main ()
> > {
> > printf("hello, world
> > \n
> >
> >
> > ");
> > system("PAUSE");
> > }
>
>
> It is valid C90 code (and not C99).
>
> The main() thing is implicit int. In C90 you could do:
>
>
> const x=7;
>
> and it was equivallent to const int x=7;
>
>
> main() was equivallent to int main(). This is not the case in C99.
>
>
> Now both in C90 and C99 if you do not declare a function and you use it,
> a declaration of the type
>
>
> int whatever_you_use(); is assumed. The empty parenthesis is not
> equivallent to (void) as in C++. Empty parenthesis means that you want
> to skip argument checking.
>
>
> So when you use printf() without <stdio.h>, int printf(); is assumed.
>
>
> Ioannis Vranos
>
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL: http://run.to/noicys
>
>
>
>
> -------------------------------------------------------
> 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
__________________________________________________
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-19 20:27:25
|
> -----Original Message-----
> From: Ioannis Vranos [mailto:no...@ho...]
> Sent: Tuesday, November 19, 2002 10:21 PM
> To: 'dev...@li...'
> Subject: RE: [Dev-C++] A simple problem
>
>
> > -----Original Message-----
> > From: dev...@li...
> > [mailto:dev...@li...] On Behalf
> > Of Paul Ardeleanu
> > Sent: Tuesday, November 19, 2002 1:47 PM
> > To: dev...@li...
> > Subject: [Dev-C++] A simple problem
> >
> >
> > Can Anyone tell me why this code WORKS FINE in DevC++?
> > ANSI C says that it any Ansi compiler should give you an
> > error (see K&R
> > book).
> > Thank you very much!
> > Paul
> >
> > -----------------------------------------------------------
> > main ()
> > {
> > printf("hello, world
> > \n
> >
> >
> > ");
> > system("PAUSE");
> > }
>
>
> It is valid C90 code (and not C99).
>
> The main() thing is implicit int. In C90 you could do:
>
>
> const x=7;
>
> and it was equivallent to const int x=7;
>
>
> main() was equivallent to int main(). This is not the case in C99.
>
>
> Now both in C90 and C99 if you do not declare a function and
> you use it, a declaration of the type
>
>
> int whatever_you_use(); is assumed. The empty parenthesis is
> not equivallent to (void) as in C++. Empty parenthesis means
> that you want to skip argument checking.
>
>
> So when you use printf() without <stdio.h>, int printf(); is assumed.
I hadn't checked the entire code. The "broken" string literal is not
guaranteed to be portable (but GCC digests it). Also in your C90 code
you have to return 0; from main(), else you have "undefined behaviour".
K&R2 doesn't return 0; from main() which was the main murmur of C
programmers. Also the castings to malloc() are not needed (=better to be
avoided ) in C, although are used in K&R 2. K&R 2 casts malloc() because
they used a prototype C++ compiler to test the code (as you can read
somewhere in the preface).
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: Ioannis V. <no...@ho...> - 2002-11-19 20:20:54
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Paul Ardeleanu
> Sent: Tuesday, November 19, 2002 1:47 PM
> To: dev...@li...
> Subject: [Dev-C++] A simple problem
>
>
> Can Anyone tell me why this code WORKS FINE in DevC++?
> ANSI C says that it any Ansi compiler should give you an
> error (see K&R
> book).
> Thank you very much!
> Paul
>
> -----------------------------------------------------------
> main ()
> {
> printf("hello, world
> \n
>
>
> ");
> system("PAUSE");
> }
It is valid C90 code (and not C99).
The main() thing is implicit int. In C90 you could do:
const x=7;
and it was equivallent to const int x=7;
main() was equivallent to int main(). This is not the case in C99.
Now both in C90 and C99 if you do not declare a function and you use it,
a declaration of the type
int whatever_you_use(); is assumed. The empty parenthesis is not
equivallent to (void) as in C++. Empty parenthesis means that you want
to skip argument checking.
So when you use printf() without <stdio.h>, int printf(); is assumed.
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: Brenden T. <br...@rc...> - 2002-11-19 18:37:13
|
Newlines are illegal in string constants, according to K&R. It's a bug,
you should reported to the DevCpp folks.
Paul Ardeleanu wrote:
>Can Anyone tell me why this code WORKS FINE in DevC++?
>ANSI C says that it any Ansi compiler should give you an error (see K&R
>book).
>Thank you very much!
>Paul
>
>-----------------------------------------------------------
>main ()
>{
> printf("hello, world
> \n
>
>
> ");
> 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: <qa...@ho...> - 2002-11-19 15:44:38
|
Make sure to test that
s->firstptr !=3D NULL
otherwise the right-hand-side of the statement
s->firstptr=3Ds->firstptr->next;
would be
NULL->next
and that is ofcourse wrong
/J
*********** REPLY SEPARATOR ***********
On 2002-11-19 at 16:23 Oroszi Bal=E1zs wrote:
>Hello j b!
>
>Monday, November 18, 2002, 8:16:12 PM, you wrote:
>
>jb> i tried to write a code using linked lists to implement the
>jb> multiplication and addition of twp polynomials but it seems i'm
>jb> not very successfull cause my pop funcition doesn't do what it
>jb> should and i don't know why i get that access violation error
>jb> ..could any one help??
>
>> /* definitions*/
>>
>> typedef struct node{
>> int coefficient;
>> int exponent;
>> struct node *next;
>> }node;
>>
>> typedef struct stack{
>> node *firstptr;
>> }stack;
>>
>> /*and the pop function*/
>>
>> node *pop(stack *s){
>> node *nptr=3Dnew node;
>> if(nptr=3D=3DNULL){
>> cout<<"exhausted memory"<<endl;
>> exit(1);
>> }
>> else{
>> nptr->coefficient=3Ds->firstptr->coefficient;
>> nptr->exponent=3Ds->firstptr->exponent;
>> s->firstptr=3Ds->firstptr->next;//that's the problematic part
>> }
>> return nptr;
>> }
>
>Well the above code shouldn't give an access violation error, IF the
>push (I assume you have a function named like that) works fine. So I
>think the problem is with the push function.
>
>And one more thing. I don't know much about C++, but I'm good at C,
>and I think you should clean up memory when you detatch a node from
>the list.
>
>Something like:
>
>node *pop(stack *s){
> node *ntmp; /* Temporary pointer */
> ...
> else{
> ...
> ntmp =3D s->firstptr; /*!*/
> s->firstptr=3Ds->firstptr->next; //that's the problematic part
> free(ntmp); /*!*/
> }
> return nprt;
>}
>
>OR:
>=3D=3D=3D
>Why not return only a pointer to the node, instead of creating a new
>one?
>Then the code would be:
>
>node *pop(stack *s){
> node *nptr; /* Only a pointer */
> nptr =3D s->firstptr;
> s->firstptr=3Ds->firstptr->next;
> return nptr;
>}
>
>Of course you will need to free the node that you get, from the
>outside.
>
>As I stated above, I don't know much about C++, but I've heard, that
>there are many built-in functions, and "things" inside C++ for list
>creation. (They are created through templates, as I remember). Look in
>the book.
>
>--
>Best regards,
> Oroszi Bal=E1zs mailto:or...@vp...
>
>PGP-FP: FB80 8A43 2664 6126 E465 46E2 2546 CFA3 C25B 9F70
>finger -l or...@se...
>
>
>
>
>-------------------------------------------------------
>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
t
|
|
From: Per W. <pw...@ia...> - 2002-11-19 15:37:18
|
By the way - where does the pop function check if there is something to
pop, i.e. that s->firtptr isn't NULL?
/Per W
On Tue, 19 Nov 2002, Oroszi Bal=E1zs wrote:
> Hello j b!
>=20
> Monday, November 18, 2002, 8:16:12 PM, you wrote:
>=20
> jb> i tried to write a code using linked lists to implement the
> jb> multiplication and addition of twp polynomials but it seems i'm
> jb> not very successfull cause my pop funcition doesn't do what it
> jb> should and i don't know why i get that access violation error
> jb> ..could any one help??
>=20
> > /* definitions*/
> >
> > typedef struct node{
> > int coefficient;
> > int exponent;
> > struct node *next;
> > }node;
> >
> > typedef struct stack{
> > node *firstptr;
> > }stack;
> >
> > /*and the pop function*/
> >=20
> > node *pop(stack *s){
> > node *nptr=3Dnew node;
> > if(nptr=3D=3DNULL){
> > cout<<"exhausted memory"<<endl;
> > exit(1);
> > }
> > else{
> > nptr->coefficient=3Ds->firstptr->coefficient;
> > nptr->exponent=3Ds->firstptr->exponent;
> > s->firstptr=3Ds->firstptr->next;//that's the problematic part
> > }
> > return nptr;
> > }
>=20
> Well the above code shouldn't give an access violation error, IF the
> push (I assume you have a function named like that) works fine. So I
> think the problem is with the push function.
>=20
> And one more thing. I don't know much about C++, but I'm good at C,
> and I think you should clean up memory when you detatch a node from
> the list.
>=20
> Something like:
>=20
> node *pop(stack *s){
> node *ntmp; /* Temporary pointer */
> ...
> else{
> ...
> ntmp =3D s->firstptr; /*!*/
> s->firstptr=3Ds->firstptr->next; //that's the problematic part
> free(ntmp); /*!*/
> }
> return nprt;
> }
>=20
> OR:
> =3D=3D=3D
> Why not return only a pointer to the node, instead of creating a new
> one?
> Then the code would be:
>=20
> node *pop(stack *s){
> node *nptr; /* Only a pointer */
> nptr =3D s->firstptr;
> s->firstptr=3Ds->firstptr->next;
> return nptr;
> }
>=20
> Of course you will need to free the node that you get, from the
> outside.
>=20
> As I stated above, I don't know much about C++, but I've heard, that
> there are many built-in functions, and "things" inside C++ for list
> creation. (They are created through templates, as I remember). Look in
> the book.
>=20
> --=20
> Best regards,
> Oroszi Bal=E1zs mailto:or...@vp...
>=20
> PGP-FP: FB80 8A43 2664 6126 E465 46E2 2546 CFA3 C25B 9F70
> finger -l or...@se... =20
>=20
>=20
>=20
>=20
> -------------------------------------------------------
> This sf.net email is sponsored by: To learn the basics of securing=20
> your web site with SSL, click here to get a FREE TRIAL of a Thawte=20
> 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
>=20
|
|
From: <or...@vp...> - 2002-11-19 15:24:37
|
Hello j b!
Monday, November 18, 2002, 8:16:12 PM, you wrote:
jb> i tried to write a code using linked lists to implement the
jb> multiplication and addition of twp polynomials but it seems i'm
jb> not very successfull cause my pop funcition doesn't do what it
jb> should and i don't know why i get that access violation error
jb> ..could any one help??
> /* definitions*/
>
> typedef struct node{
> int coefficient;
> int exponent;
> struct node *next;
> }node;
>
> typedef struct stack{
> node *firstptr;
> }stack;
>
> /*and the pop function*/
>
> node *pop(stack *s){
> node *nptr=new node;
> if(nptr==NULL){
> cout<<"exhausted memory"<<endl;
> exit(1);
> }
> else{
> nptr->coefficient=s->firstptr->coefficient;
> nptr->exponent=s->firstptr->exponent;
> s->firstptr=s->firstptr->next;//that's the problematic part
> }
> return nptr;
> }
Well the above code shouldn't give an access violation error, IF the
push (I assume you have a function named like that) works fine. So I
think the problem is with the push function.
And one more thing. I don't know much about C++, but I'm good at C,
and I think you should clean up memory when you detatch a node from
the list.
Something like:
node *pop(stack *s){
node *ntmp; /* Temporary pointer */
...
else{
...
ntmp = s->firstptr; /*!*/
s->firstptr=s->firstptr->next; //that's the problematic part
free(ntmp); /*!*/
}
return nprt;
}
OR:
===
Why not return only a pointer to the node, instead of creating a new
one?
Then the code would be:
node *pop(stack *s){
node *nptr; /* Only a pointer */
nptr = s->firstptr;
s->firstptr=s->firstptr->next;
return nptr;
}
Of course you will need to free the node that you get, from the
outside.
As I stated above, I don't know much about C++, but I've heard, that
there are many built-in functions, and "things" inside C++ for list
creation. (They are created through templates, as I remember). Look in
the book.
--
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: Louis G. <lg...@ya...> - 2002-11-19 14:58:22
|
What are the plans for the Dev++ 5 update ? Will it be integrated with the INSIGHT debugger ? __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - Let the expert host your site http://webhosting.yahoo.com |
|
From: Daniel G. <sp...@ho...> - 2002-11-19 14:39:43
|
Just wondering, does anyone have a small C++ program that tests the system performance? I'm asking b/c my second Pc has a fast processor (700mhz) but is behaving sluggishly, so I'd like to test it without writing a huge program. Don't know where to start with this, so examples and suggestions would be great. _________________________________________________________________ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail |
|
From: xiaoqiang <lil...@so...> - 2002-11-19 12:51:54
|
dGh4IQ0KDQogCQkJCQ0KoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoXhpYW9xaWFuZw0KoaGh oaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoWxpbGFveWFvQHNvaHUuY29tDQqhoaGhoaGhoaGhoaGh oaGhoaGhoaGhoaGhoaGhoaGhoaGhMjAwMi0xMS0xOQ0K |
|
From: Daniel G. <sp...@ho...> - 2002-11-19 12:41:22
|
whitespace is ignored, I think that's the answer. _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus |
|
From: Arnvid K. <ar...@ka...> - 2002-11-19 12:36:40
|
On Tue, 19 Nov 2002 11:47:21 +0000 (GMT) - Paul Ardeleanu <par...@ya...> wrote:
> Can Anyone tell me why this code WORKS FINE in DevC++?
> ANSI C says that it any Ansi compiler should give you an error (see K&R
> book).
> Thank you very much!
> Paul
>
> -----------------------------------------------------------
> main ()
> {
> printf("hello, world
> \n
>
>
> ");
> system("PAUSE");
> }
A good thing in c is always to do a
return 0;
before the last } in main... gcc and many other compilers complain if
you don't. so keep the compilers happy ;)
|
|
From: Daniel G. <sp...@ho...> - 2002-11-19 12:19:26
|
DEV-C++ assumes the return type of the function is an INT and sorts the
problem.
>From: Paul Ardeleanu <par...@ya...>
>To: dev...@li...
>Subject: [Dev-C++] A simple problem
>Date: Tue, 19 Nov 2002 11:47:21 +0000 (GMT)
>
>Can Anyone tell me why this code WORKS FINE in DevC++?
>ANSI C says that it any Ansi compiler should give you an error (see K&R
>book).
>Thank you very much!
>Paul
>
>-----------------------------------------------------------
>main ()
>{
> printf("hello, world
> \n
>
>
> ");
> 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
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail
|
|
From: <par...@ya...> - 2002-11-19 11:47:27
|
Can Anyone tell me why this code WORKS FINE in DevC++?
ANSI C says that it any Ansi compiler should give you an error (see K&R
book).
Thank you very much!
Paul
-----------------------------------------------------------
main ()
{
printf("hello, world
\n
");
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: <il...@sl...> - 2002-11-19 10:41:00
|
Hello, When is Dev-C++ 5 coming out? I'm using this 4.9.6.0 release and I have huge problems getting the code completion to work and it makes coding very frustrating since you have look at the other sources all the time. Any tips for that? I have enabled the code completion at the user options. Best regards, Ilkka Seppälä |
|
From: Arnvid K. <ar...@ka...> - 2002-11-18 21:33:16
|
> > I was trying some limits.h and im having errors > > my sample code: > > #include<iostream.h> > #include <iostream> I don't really think that's gonna help him much, since then the compiler won't find the needed .h files... Med vennlig hilsen/Best regards, Arnvid L. Karstad Internet Service Design IBM eServer Certified Specialist - p690 Technical Support IBM eServer Certified Specialist - pSeries AIX5 System Support IBM Certified Networking Solutions Enginer 1 CCNA - Cisco Certified Network Associate |