dev-cpp-users Mailing List for Dev-C++ (Page 62)
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: William J. <W-J...@ne...> - 2007-05-10 16:35:15
|
I am looking for templates for creating plugins using Fusion 5 SDK from eyeon software http://eyeonline.com ... Please advise. Regards, William |
From: Per W. <pw...@ia...> - 2007-05-10 14:16:53
|
Do not try sizeof(strlen(str)); That is a fixed value - the size of the data type returned by strlen (normally size_t, if runtime library is compliant with the C standard). You want to allocate (strlen(str)+1) bytes, i.e. one byte for each character in the string, and an extra byte for the termination. An easier way to allocate and assign at the same time is to do name = strdup(str); Also, you have mixed up data types. If the list entries are struct list, then that is the data type that the queue entry should have for it's 'front' pointer. /pwm On Thu, 10 May 2007, Jan Mura wrote: > Hello, > > I have got two more things about the allocation of pointer types. > > I have structure like: > > struct list > { > int id; > char *name; > struct list *next; > }; > > struct list *element; > > Should now I do something like: > > element = malloc(sizeof(struct(list element)); > element->name = malloc(sizeof(strlen("some string here"))); > element->next = malloc(sizeof(struct list((; > > ...main program here... > > free(element->next); > free(element->name); > > ? > > And the second thing, more about the alghoritgm of connected list or how is > it called. > The structure above defines an element of such a list. Where there is NULL > in element->next it means it is the last element in the list. And I have > another structure defined like: > > typedef struct Queue{ > struct bet_list *front; > }Queue; > Queue *q; > > I store an adress to the first element in the list in q. > Is this correct? Or is there some more commone and easier way? > > Thank you again > > Jan Mura > jan...@vo... > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Jan M. <jan...@vo...> - 2007-05-10 14:00:19
|
Hello, I have got two more things about the allocation of pointer types. I have structure like: struct list { int id; char *name; struct list *next; }; struct list *element; Should now I do something like: element = malloc(sizeof(struct(list element)); element->name = malloc(sizeof(strlen("some string here"))); element->next = malloc(sizeof(struct list((; ...main program here... free(element->next); free(element->name); ? And the second thing, more about the alghoritgm of connected list or how is it called. The structure above defines an element of such a list. Where there is NULL in element->next it means it is the last element in the list. And I have another structure defined like: typedef struct Queue{ struct bet_list *front; }Queue; Queue *q; I store an adress to the first element in the list in q. Is this correct? Or is there some more commone and easier way? Thank you again Jan Mura jan...@vo... |
From: Per W. <pw...@ia...> - 2007-05-07 13:32:10
|
Note that strdup() can be used to both allocate memory for a string, and copy the string data to the allocated buffer. /pwm On Mon, 7 May 2007, Jan Mura wrote: > Oh God, thank you. It is enough for today I think. > > Jan Mura > ----- Original Message ----- > From: "Jonathan Winterflood" <jon...@gm...> > To: "Jan Mura" <jan...@vo...> > Cc: "Per Westermark" <pw...@ia...>; "Philip Bennefall" > <phi...@pb...>; <dev...@li...> > Sent: Monday, May 07, 2007 12:32 PM > Subject: Re: [Dev-C++] Casting of int to string > > > > Since the name is just a pointer, the malloc does not allocate _any_ > memory > > for the name, only 4 bytes(?) for the pointer. > > You should seperately allocate the memory for the name, or use another > > trick: allocte enough memory _after_ the structure to contain your name, > in > > the same malloc (this saves allocating lots of small blocks, in the case > > that the name for that structure will not change) > > eg: > > member = malloc(sizeof(struct bet_list)+length_of_name_including_nul); > > //allocate both > > member->name = (char *)member + sizeof(struct bet_list); // point the > name > > at the memory after the structure > > strcpy(member->name, name); > > > > It might look slightly hacky, but it works fine :) > > Any comments on this? > > > > Obviously if you dno't know the size of the string before allocatingthe > > struct, or it may change, you'll have to allocate them separately: > > > > member = malloc(sizeof(struct bet_list)); //allocate just one > > member->name=NULL; // for checking: malloc does not initialize data (I > guess > > you already know that) > > member->next = NULL; > > /* ... */ > > if (member->name) { > > free(member->name); //in case you are changing names > > member->name=NULL; // if you aren't going to put the name back > immediately > > } > > member->name = malloc(strlen(name)+1); //allocate the name > > strcpy(member->name, name); > > > > Jonathan > > > > On 5/7/07, Jan Mura <jan...@vo...> wrote: > > > > > > > > > Thank you, it came to my mind what about the NULL character at the end > of > > > the string. > > > > > > Maybe one more thing. I am not sure if my code is ok because of the > > > similar > > > reasons about some illegal memory usage. > > > So I have something like > > > > > > struct bet_list > > > { > > > int id; > > > char *name; > > > struct bet_list *next; > > > }; > > > ... > > > struct bet_list *member, *temp; > > > > > > member = malloc(sizeof(struct bet_list)); > > > > > > member->id = 1; > > > strcpy(member->name, "some string here"); > > > member->next = NULL; > > > > > > ... > > > > > > I am not sure if malloc allocates enough space if it dont know how long > is > > > a > > > string I would like to put in. > > > > > > Thanks again > > > > > > Jan Mura > > > > > > ---- Original Message ----- > > > From: "Per Westermark" <pw...@ia...> > > > To: "Philip Bennefall" <phi...@pb...> > > > Cc: "Jonathan Winterflood" <jon...@gm...>; "Jan Mura" > > > <jan...@vo...>; <dev...@li...> > > > Sent: Monday, May 07, 2007 10:21 AM > > > Subject: Re: [Dev-C++] Casting of int to string > > > > > > > > > > Better C libraries have the snprintf() function, that takes the size > of > > > > the buffer as an input parameter. > > > > > > > > /pwm > > > > > > > > On Mon, 7 May 2007, Philip Bennefall wrote: > > > > > > > > > Sorry, I should've phrased it differently. Yup, allocating too > little > > > memory is a bad idea in any situation because the function has no way of > > > knowing when it is supposed to stop writing. I just put 32 in there > > > because > > > it ensures (100 %) that the entire value will be stored including the > Null > > > terminator. > > > > > > > > > > Regards > > > > > Philip Bennefall > > > > > ----- Original Message ----- > > > > > From: Jonathan Winterflood > > > > > To: Jan Mura > > > > > Cc: dev...@li... > > > > > Sent: Monday, May 07, 2007 9:08 AM > > > > > Subject: Re: [Dev-C++] Casting of int to string > > > > > > > > > > > > > > > Just a note: > > > > > """ It basically prints your integer into the character array, as > > > long > > > as there is enough space to hold it """ > > > > > Actually it will print the integer whether there is enough space > or > > > not.. It is entirely Your job to make sure there is enough space, or > else > > > sprintf will just keep on printing in memory after the end of the array. > > > Obviously this is a very bad idea, since there is other data there. > > > > > In this case, determining the necessary space is as easy as > 'what's > > > the maximum digit count in an integer'... but in other cases, you can > get > > > wierd crashes, wrong data for no apparent reason, or even create an > > > exploit > > > in your program. > > > > > > > > > > Thought you might want to know that (and if you did, no offense > > > intended :) > > > > > Jonathan > > > > > > > > > > > > > > > On 5/7/07, Philip Bennefall < phi...@pb...> > wrote: > > > > > This will do the job. > > > > > char outputstring[32]; > > > > > sprintf(outputstring, "%d", integer); > > > > > > > > > > It basically prints your integer into the character array, as > long > > > as there > > > > > is enough space to hold it. This method works both in C and C++. > > > There are > > > > > other methods such as stringstream, but they only work in C++. > If > > > you're > > > > > compiling a C program, for this function to work you need to > > > include > > > stdio.h > > > > > and for C++ it is cstdio. > > > > > > > > > > Regards > > > > > Philip Bennefall > > > > > ----- Original Message ----- > > > > > From: "Jan Mura" <jan...@vo...> > > > > > To: <dev...@li... > > > > > > Sent: Monday, May 07, 2007 8:26 AM > > > > > Subject: [Dev-C++] Casting of int to string > > > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > I would like to compare an integer with a string using > strcmp(). > > > So I need > > > > > > to cast the int type to string (*char). Is there some commone > > > way > > > how to > > > > > > do > > > > > > it. Should I use & operator and adress of int in teh > function? > > > Or > > > > > > something > > > > > > else? > > > > > > > > > > > > Thank you very much > > > > > > > > > > > > Jan Mura > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > This SF.net email is sponsored by DB2 Express > > > > > > Download DB2 Express C - the FREE version of DB2 express and > > > take > > > > > > control of your XML. No limits. Just data. Click to get it > now. > > > > > > http://sourceforge.net/powerbar/db2/ > > > > > > _______________________________________________ > > > > > > Dev-cpp-users mailing list > > > > > > Dev...@li... > > > > > > TO UNSUBSCRIBE: > http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > This SF.net email is sponsored by DB2 Express > > > > > Download DB2 Express C - the FREE version of DB2 express and > take > > > > > control of your XML. No limits. Just data. Click to get it now. > > > > > http://sourceforge.net/powerbar/db2/ > > > > > _______________________________________________ > > > > > Dev-cpp-users mailing list > > > > > Dev...@li... > > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > <Morpheus> linux, c'est une question de VI ou de MORE > > > > > > > > > > > > > > > > > > > > > > -------------------------------------------------------------------------- > > > ---- > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > This SF.net email is sponsored by DB2 Express > > > > > Download DB2 Express C - the FREE version of DB2 express and take > > > > > control of your XML. No limits. Just data. Click to get it now. > > > > > http://sourceforge.net/powerbar/db2/ > > > > > > > > > > > > > > > > > > > > > > -------------------------------------------------------------------------- > > > ---- > > > > > > > > > > > > > > > _______________________________________________ > > > > > Dev-cpp-users mailing list > > > > > Dev...@li... > > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > > __________ Informace od NOD32 2245 (20070506) __________ > > > > > > > > Tato zprava byla proverena antivirovym systemem NOD32. > > > > http://www.nod32.cz > > > > > > > > > > > > > > > > > > > > -- > > <Morpheus> linux, c'est une question de VI ou de MORE > > > > > > > > __________ Informace od NOD32 2246 (20070507) __________ > > > > Tato zprava byla proverena antivirovym systemem NOD32. > > http://www.nod32.cz > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Jan M. <jan...@vo...> - 2007-05-07 10:56:09
|
Oh God, thank you. It is enough for today I think. Jan Mura ----- Original Message ----- From: "Jonathan Winterflood" <jon...@gm...> To: "Jan Mura" <jan...@vo...> Cc: "Per Westermark" <pw...@ia...>; "Philip Bennefall" <phi...@pb...>; <dev...@li...> Sent: Monday, May 07, 2007 12:32 PM Subject: Re: [Dev-C++] Casting of int to string > Since the name is just a pointer, the malloc does not allocate _any_ memory > for the name, only 4 bytes(?) for the pointer. > You should seperately allocate the memory for the name, or use another > trick: allocte enough memory _after_ the structure to contain your name, in > the same malloc (this saves allocating lots of small blocks, in the case > that the name for that structure will not change) > eg: > member = malloc(sizeof(struct bet_list)+length_of_name_including_nul); > //allocate both > member->name = (char *)member + sizeof(struct bet_list); // point the name > at the memory after the structure > strcpy(member->name, name); > > It might look slightly hacky, but it works fine :) > Any comments on this? > > Obviously if you dno't know the size of the string before allocatingthe > struct, or it may change, you'll have to allocate them separately: > > member = malloc(sizeof(struct bet_list)); //allocate just one > member->name=NULL; // for checking: malloc does not initialize data (I guess > you already know that) > member->next = NULL; > /* ... */ > if (member->name) { > free(member->name); //in case you are changing names > member->name=NULL; // if you aren't going to put the name back immediately > } > member->name = malloc(strlen(name)+1); //allocate the name > strcpy(member->name, name); > > Jonathan > > On 5/7/07, Jan Mura <jan...@vo...> wrote: > > > > > > Thank you, it came to my mind what about the NULL character at the end of > > the string. > > > > Maybe one more thing. I am not sure if my code is ok because of the > > similar > > reasons about some illegal memory usage. > > So I have something like > > > > struct bet_list > > { > > int id; > > char *name; > > struct bet_list *next; > > }; > > ... > > struct bet_list *member, *temp; > > > > member = malloc(sizeof(struct bet_list)); > > > > member->id = 1; > > strcpy(member->name, "some string here"); > > member->next = NULL; > > > > ... > > > > I am not sure if malloc allocates enough space if it dont know how long is > > a > > string I would like to put in. > > > > Thanks again > > > > Jan Mura > > > > ---- Original Message ----- > > From: "Per Westermark" <pw...@ia...> > > To: "Philip Bennefall" <phi...@pb...> > > Cc: "Jonathan Winterflood" <jon...@gm...>; "Jan Mura" > > <jan...@vo...>; <dev...@li...> > > Sent: Monday, May 07, 2007 10:21 AM > > Subject: Re: [Dev-C++] Casting of int to string > > > > > > > Better C libraries have the snprintf() function, that takes the size of > > > the buffer as an input parameter. > > > > > > /pwm > > > > > > On Mon, 7 May 2007, Philip Bennefall wrote: > > > > > > > Sorry, I should've phrased it differently. Yup, allocating too little > > memory is a bad idea in any situation because the function has no way of > > knowing when it is supposed to stop writing. I just put 32 in there > > because > > it ensures (100 %) that the entire value will be stored including the Null > > terminator. > > > > > > > > Regards > > > > Philip Bennefall > > > > ----- Original Message ----- > > > > From: Jonathan Winterflood > > > > To: Jan Mura > > > > Cc: dev...@li... > > > > Sent: Monday, May 07, 2007 9:08 AM > > > > Subject: Re: [Dev-C++] Casting of int to string > > > > > > > > > > > > Just a note: > > > > """ It basically prints your integer into the character array, as > > long > > as there is enough space to hold it """ > > > > Actually it will print the integer whether there is enough space or > > not.. It is entirely Your job to make sure there is enough space, or else > > sprintf will just keep on printing in memory after the end of the array. > > Obviously this is a very bad idea, since there is other data there. > > > > In this case, determining the necessary space is as easy as 'what's > > the maximum digit count in an integer'... but in other cases, you can get > > wierd crashes, wrong data for no apparent reason, or even create an > > exploit > > in your program. > > > > > > > > Thought you might want to know that (and if you did, no offense > > intended :) > > > > Jonathan > > > > > > > > > > > > On 5/7/07, Philip Bennefall < phi...@pb...> wrote: > > > > This will do the job. > > > > char outputstring[32]; > > > > sprintf(outputstring, "%d", integer); > > > > > > > > It basically prints your integer into the character array, as long > > as there > > > > is enough space to hold it. This method works both in C and C++. > > There are > > > > other methods such as stringstream, but they only work in C++. If > > you're > > > > compiling a C program, for this function to work you need to > > include > > stdio.h > > > > and for C++ it is cstdio. > > > > > > > > Regards > > > > Philip Bennefall > > > > ----- Original Message ----- > > > > From: "Jan Mura" <jan...@vo...> > > > > To: <dev...@li... > > > > > Sent: Monday, May 07, 2007 8:26 AM > > > > Subject: [Dev-C++] Casting of int to string > > > > > > > > > > > > > Hello, > > > > > > > > > > I would like to compare an integer with a string using strcmp(). > > So I need > > > > > to cast the int type to string (*char). Is there some commone > > way > > how to > > > > > do > > > > > it. Should I use & operator and adress of int in teh function? > > Or > > > > > something > > > > > else? > > > > > > > > > > Thank you very much > > > > > > > > > > Jan Mura > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > This SF.net email is sponsored by DB2 Express > > > > > Download DB2 Express C - the FREE version of DB2 express and > > take > > > > > control of your XML. No limits. Just data. Click to get it now. > > > > > http://sourceforge.net/powerbar/db2/ > > > > > _______________________________________________ > > > > > Dev-cpp-users mailing list > > > > > Dev...@li... > > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > This SF.net email is sponsored by DB2 Express > > > > Download DB2 Express C - the FREE version of DB2 express and take > > > > control of your XML. No limits. Just data. Click to get it now. > > > > http://sourceforge.net/powerbar/db2/ > > > > _______________________________________________ > > > > Dev-cpp-users mailing list > > > > Dev...@li... > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > > > > > -- > > > > <Morpheus> linux, c'est une question de VI ou de MORE > > > > > > > > > > > > > > > > -------------------------------------------------------------------------- > > ---- > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > This SF.net email is sponsored by DB2 Express > > > > Download DB2 Express C - the FREE version of DB2 express and take > > > > control of your XML. No limits. Just data. Click to get it now. > > > > http://sourceforge.net/powerbar/db2/ > > > > > > > > > > > > > > > > -------------------------------------------------------------------------- > > ---- > > > > > > > > > > > > _______________________________________________ > > > > Dev-cpp-users mailing list > > > > Dev...@li... > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > > __________ Informace od NOD32 2245 (20070506) __________ > > > > > > Tato zprava byla proverena antivirovym systemem NOD32. > > > http://www.nod32.cz > > > > > > > > > > > > > -- > <Morpheus> linux, c'est une question de VI ou de MORE > > > > __________ Informace od NOD32 2246 (20070507) __________ > > Tato zprava byla proverena antivirovym systemem NOD32. > http://www.nod32.cz > |
From: Mux0x55 <mu...@gm...> - 2007-05-07 10:36:56
|
Jonathan Winterflood ha scritto: > When you create the project you put the code in, you should select the > language to use (bottom-right of the dialog) > Also, in Project Options > Files, you can change the settings on a > file-by-file basis. > > Happy coding :) > > Jonathan > > On 5/7/07, *Mux0x55 otto a uno* <mu...@gm... > <mailto:mu...@gm...>> wrote: > > Good evening @ all, > I have a big problem. I want to use DevCpp to compile C progs > only, but I can't compile because it gives me this compilation > error: "redeclaration of built in type bool". How can I solve the > problem? Is there a method to disable c++ compiler ? Help me > please. I'm a student of IT Engineering and I'm using the Roberts > library of "Programming with abstractions in C" . I have to > use the devCpp and I have to use these libraries. Help me again. > Thank You. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > <mailto:Dev...@li...> > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > <https://lists.sourceforge.net/lists/listinfo/dev-cpp-users> > > I do this , but It doesn't work... I have always this compile error... > -- > <Morpheus> linux, c'est une question de VI ou de MORE |
From: Jonathan W. <jon...@gm...> - 2007-05-07 10:33:02
|
Since the name is just a pointer, the malloc does not allocate _any_ memory for the name, only 4 bytes(?) for the pointer. You should seperately allocate the memory for the name, or use another trick: allocte enough memory _after_ the structure to contain your name, in the same malloc (this saves allocating lots of small blocks, in the case that the name for that structure will not change) eg: member = malloc(sizeof(struct bet_list)+length_of_name_including_nul); //allocate both member->name = (char *)member + sizeof(struct bet_list); // point the name at the memory after the structure strcpy(member->name, name); It might look slightly hacky, but it works fine :) Any comments on this? Obviously if you dno't know the size of the string before allocatingthe struct, or it may change, you'll have to allocate them separately: member = malloc(sizeof(struct bet_list)); //allocate just one member->name=NULL; // for checking: malloc does not initialize data (I guess you already know that) member->next = NULL; /* ... */ if (member->name) { free(member->name); //in case you are changing names member->name=NULL; // if you aren't going to put the name back immediately } member->name = malloc(strlen(name)+1); //allocate the name strcpy(member->name, name); Jonathan On 5/7/07, Jan Mura <jan...@vo...> wrote: > > > Thank you, it came to my mind what about the NULL character at the end of > the string. > > Maybe one more thing. I am not sure if my code is ok because of the > similar > reasons about some illegal memory usage. > So I have something like > > struct bet_list > { > int id; > char *name; > struct bet_list *next; > }; > ... > struct bet_list *member, *temp; > > member = malloc(sizeof(struct bet_list)); > > member->id = 1; > strcpy(member->name, "some string here"); > member->next = NULL; > > ... > > I am not sure if malloc allocates enough space if it dont know how long is > a > string I would like to put in. > > Thanks again > > Jan Mura > > ---- Original Message ----- > From: "Per Westermark" <pw...@ia...> > To: "Philip Bennefall" <phi...@pb...> > Cc: "Jonathan Winterflood" <jon...@gm...>; "Jan Mura" > <jan...@vo...>; <dev...@li...> > Sent: Monday, May 07, 2007 10:21 AM > Subject: Re: [Dev-C++] Casting of int to string > > > > Better C libraries have the snprintf() function, that takes the size of > > the buffer as an input parameter. > > > > /pwm > > > > On Mon, 7 May 2007, Philip Bennefall wrote: > > > > > Sorry, I should've phrased it differently. Yup, allocating too little > memory is a bad idea in any situation because the function has no way of > knowing when it is supposed to stop writing. I just put 32 in there > because > it ensures (100 %) that the entire value will be stored including the Null > terminator. > > > > > > Regards > > > Philip Bennefall > > > ----- Original Message ----- > > > From: Jonathan Winterflood > > > To: Jan Mura > > > Cc: dev...@li... > > > Sent: Monday, May 07, 2007 9:08 AM > > > Subject: Re: [Dev-C++] Casting of int to string > > > > > > > > > Just a note: > > > """ It basically prints your integer into the character array, as > long > as there is enough space to hold it """ > > > Actually it will print the integer whether there is enough space or > not.. It is entirely Your job to make sure there is enough space, or else > sprintf will just keep on printing in memory after the end of the array. > Obviously this is a very bad idea, since there is other data there. > > > In this case, determining the necessary space is as easy as 'what's > the maximum digit count in an integer'... but in other cases, you can get > wierd crashes, wrong data for no apparent reason, or even create an > exploit > in your program. > > > > > > Thought you might want to know that (and if you did, no offense > intended :) > > > Jonathan > > > > > > > > > On 5/7/07, Philip Bennefall < phi...@pb...> wrote: > > > This will do the job. > > > char outputstring[32]; > > > sprintf(outputstring, "%d", integer); > > > > > > It basically prints your integer into the character array, as long > as there > > > is enough space to hold it. This method works both in C and C++. > There are > > > other methods such as stringstream, but they only work in C++. If > you're > > > compiling a C program, for this function to work you need to > include > stdio.h > > > and for C++ it is cstdio. > > > > > > Regards > > > Philip Bennefall > > > ----- Original Message ----- > > > From: "Jan Mura" <jan...@vo...> > > > To: <dev...@li... > > > > Sent: Monday, May 07, 2007 8:26 AM > > > Subject: [Dev-C++] Casting of int to string > > > > > > > > > > Hello, > > > > > > > > I would like to compare an integer with a string using strcmp(). > So I need > > > > to cast the int type to string (*char). Is there some commone > way > how to > > > > do > > > > it. Should I use & operator and adress of int in teh function? > Or > > > > something > > > > else? > > > > > > > > Thank you very much > > > > > > > > Jan Mura > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > This SF.net email is sponsored by DB2 Express > > > > Download DB2 Express C - the FREE version of DB2 express and > take > > > > control of your XML. No limits. Just data. Click to get it now. > > > > http://sourceforge.net/powerbar/db2/ > > > > _______________________________________________ > > > > Dev-cpp-users mailing list > > > > Dev...@li... > > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by DB2 Express > > > Download DB2 Express C - the FREE version of DB2 express and take > > > control of your XML. No limits. Just data. Click to get it now. > > > http://sourceforge.net/powerbar/db2/ > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > > > > -- > > > <Morpheus> linux, c'est une question de VI ou de MORE > > > > > > > > > > > -------------------------------------------------------------------------- > ---- > > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by DB2 Express > > > Download DB2 Express C - the FREE version of DB2 express and take > > > control of your XML. No limits. Just data. Click to get it now. > > > http://sourceforge.net/powerbar/db2/ > > > > > > > > > > > -------------------------------------------------------------------------- > ---- > > > > > > > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > __________ Informace od NOD32 2245 (20070506) __________ > > > > Tato zprava byla proverena antivirovym systemem NOD32. > > http://www.nod32.cz > > > > > > -- <Morpheus> linux, c'est une question de VI ou de MORE |
From: Jan M. <jan...@vo...> - 2007-05-07 09:21:26
|
Thank you, it came to my mind what about the NULL character at the end of the string. Maybe one more thing. I am not sure if my code is ok because of the similar reasons about some illegal memory usage. So I have something like struct bet_list { int id; char *name; struct bet_list *next; }; ... struct bet_list *member, *temp; member = malloc(sizeof(struct bet_list)); member->id = 1; strcpy(member->name, "some string here"); member->next = NULL; ... I am not sure if malloc allocates enough space if it dont know how long is a string I would like to put in. Thanks again Jan Mura ---- Original Message ----- From: "Per Westermark" <pw...@ia...> To: "Philip Bennefall" <phi...@pb...> Cc: "Jonathan Winterflood" <jon...@gm...>; "Jan Mura" <jan...@vo...>; <dev...@li...> Sent: Monday, May 07, 2007 10:21 AM Subject: Re: [Dev-C++] Casting of int to string > Better C libraries have the snprintf() function, that takes the size of > the buffer as an input parameter. > > /pwm > > On Mon, 7 May 2007, Philip Bennefall wrote: > > > Sorry, I should've phrased it differently. Yup, allocating too little memory is a bad idea in any situation because the function has no way of knowing when it is supposed to stop writing. I just put 32 in there because it ensures (100 %) that the entire value will be stored including the Null terminator. > > > > Regards > > Philip Bennefall > > ----- Original Message ----- > > From: Jonathan Winterflood > > To: Jan Mura > > Cc: dev...@li... > > Sent: Monday, May 07, 2007 9:08 AM > > Subject: Re: [Dev-C++] Casting of int to string > > > > > > Just a note: > > """ It basically prints your integer into the character array, as long as there is enough space to hold it """ > > Actually it will print the integer whether there is enough space or not.. It is entirely Your job to make sure there is enough space, or else sprintf will just keep on printing in memory after the end of the array. Obviously this is a very bad idea, since there is other data there. > > In this case, determining the necessary space is as easy as 'what's the maximum digit count in an integer'... but in other cases, you can get wierd crashes, wrong data for no apparent reason, or even create an exploit in your program. > > > > Thought you might want to know that (and if you did, no offense intended :) > > Jonathan > > > > > > On 5/7/07, Philip Bennefall < phi...@pb...> wrote: > > This will do the job. > > char outputstring[32]; > > sprintf(outputstring, "%d", integer); > > > > It basically prints your integer into the character array, as long as there > > is enough space to hold it. This method works both in C and C++. There are > > other methods such as stringstream, but they only work in C++. If you're > > compiling a C program, for this function to work you need to include stdio.h > > and for C++ it is cstdio. > > > > Regards > > Philip Bennefall > > ----- Original Message ----- > > From: "Jan Mura" <jan...@vo...> > > To: <dev...@li... > > > Sent: Monday, May 07, 2007 8:26 AM > > Subject: [Dev-C++] Casting of int to string > > > > > > > Hello, > > > > > > I would like to compare an integer with a string using strcmp(). So I need > > > to cast the int type to string (*char). Is there some commone way how to > > > do > > > it. Should I use & operator and adress of int in teh function? Or > > > something > > > else? > > > > > > Thank you very much > > > > > > Jan Mura > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by DB2 Express > > > Download DB2 Express C - the FREE version of DB2 express and take > > > control of your XML. No limits. Just data. Click to get it now. > > > http://sourceforge.net/powerbar/db2/ > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > -- > > <Morpheus> linux, c'est une question de VI ou de MORE > > > > > > -------------------------------------------------------------------------- ---- > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > > > > > -------------------------------------------------------------------------- ---- > > > > > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > __________ Informace od NOD32 2245 (20070506) __________ > > Tato zprava byla proverena antivirovym systemem NOD32. > http://www.nod32.cz > > |
From: Per W. <pw...@ia...> - 2007-05-07 08:22:29
|
Better C libraries have the snprintf() function, that takes the size of the buffer as an input parameter. /pwm On Mon, 7 May 2007, Philip Bennefall wrote: > Sorry, I should've phrased it differently. Yup, allocating too little memory is a bad idea in any situation because the function has no way of knowing when it is supposed to stop writing. I just put 32 in there because it ensures (100 %) that the entire value will be stored including the Null terminator. > > Regards > Philip Bennefall > ----- Original Message ----- > From: Jonathan Winterflood > To: Jan Mura > Cc: dev...@li... > Sent: Monday, May 07, 2007 9:08 AM > Subject: Re: [Dev-C++] Casting of int to string > > > Just a note: > """ It basically prints your integer into the character array, as long as there is enough space to hold it """ > Actually it will print the integer whether there is enough space or not.. It is entirely Your job to make sure there is enough space, or else sprintf will just keep on printing in memory after the end of the array. Obviously this is a very bad idea, since there is other data there. > In this case, determining the necessary space is as easy as 'what's the maximum digit count in an integer'... but in other cases, you can get wierd crashes, wrong data for no apparent reason, or even create an exploit in your program. > > Thought you might want to know that (and if you did, no offense intended :) > Jonathan > > > On 5/7/07, Philip Bennefall < phi...@pb...> wrote: > This will do the job. > char outputstring[32]; > sprintf(outputstring, "%d", integer); > > It basically prints your integer into the character array, as long as there > is enough space to hold it. This method works both in C and C++. There are > other methods such as stringstream, but they only work in C++. If you're > compiling a C program, for this function to work you need to include stdio.h > and for C++ it is cstdio. > > Regards > Philip Bennefall > ----- Original Message ----- > From: "Jan Mura" <jan...@vo...> > To: <dev...@li... > > Sent: Monday, May 07, 2007 8:26 AM > Subject: [Dev-C++] Casting of int to string > > > > Hello, > > > > I would like to compare an integer with a string using strcmp(). So I need > > to cast the int type to string (*char). Is there some commone way how to > > do > > it. Should I use & operator and adress of int in teh function? Or > > something > > else? > > > > Thank you very much > > > > Jan Mura > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > -- > <Morpheus> linux, c'est une question de VI ou de MORE > > > ------------------------------------------------------------------------------ > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Philip B. <phi...@pb...> - 2007-05-07 07:30:39
|
Sorry, I should've phrased it differently. Yup, allocating too little = memory is a bad idea in any situation because the function has no way of = knowing when it is supposed to stop writing. I just put 32 in there = because it ensures (100 %) that the entire value will be stored = including the Null terminator. Regards Philip Bennefall ----- Original Message -----=20 From: Jonathan Winterflood=20 To: Jan Mura=20 Cc: dev...@li...=20 Sent: Monday, May 07, 2007 9:08 AM Subject: Re: [Dev-C++] Casting of int to string Just a note: """ It basically prints your integer into the character array, as long = as there is enough space to hold it """ Actually it will print the integer whether there is enough space or = not.. It is entirely Your job to make sure there is enough space, or = else sprintf will just keep on printing in memory after the end of the = array. Obviously this is a very bad idea, since there is other data = there.=20 In this case, determining the necessary space is as easy as 'what's = the maximum digit count in an integer'... but in other cases, you can = get wierd crashes, wrong data for no apparent reason, or even create an = exploit in your program.=20 Thought you might want to know that (and if you did, no offense = intended :) Jonathan On 5/7/07, Philip Bennefall < phi...@pb...> wrote: This will do the job. char outputstring[32]; sprintf(outputstring, "%d", integer); It basically prints your integer into the character array, as long = as there is enough space to hold it. This method works both in C and C++. = There are=20 other methods such as stringstream, but they only work in C++. If = you're compiling a C program, for this function to work you need to include = stdio.h and for C++ it is cstdio. Regards Philip Bennefall=20 ----- Original Message ----- From: "Jan Mura" <jan...@vo...> To: <dev...@li... > Sent: Monday, May 07, 2007 8:26 AM Subject: [Dev-C++] Casting of int to string > Hello, > > I would like to compare an integer with a string using strcmp(). = So I need > to cast the int type to string (*char). Is there some commone way = how to=20 > do > it. Should I use & operator and adress of int in teh function? Or > something > else? > > Thank you very much > > Jan Mura > > > = -------------------------------------------------------------------------= =20 > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li...=20 > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=20 > = -------------------------------------------------------------------------= This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.=20 http://sourceforge.net/powerbar/db2/ _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users --=20 <Morpheus> linux, c'est une question de VI ou de MORE=20 -------------------------------------------------------------------------= ----- = -------------------------------------------------------------------------= This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ -------------------------------------------------------------------------= ----- _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
From: Jonathan W. <jon...@gm...> - 2007-05-07 07:08:33
|
Just a note: """ It basically prints your integer into the character array, as long as there is enough space to hold it """ Actually it will print the integer whether there is enough space or not.. It is entirely Your job to make sure there is enough space, or else sprintf will just keep on printing in memory after the end of the array. Obviously this is a very bad idea, since there is other data there. In this case, determining the necessary space is as easy as 'what's the maximum digit count in an integer'... but in other cases, you can get wierd crashes, wrong data for no apparent reason, or even create an exploit in your program. Thought you might want to know that (and if you did, no offense intended :) Jonathan On 5/7/07, Philip Bennefall <phi...@pb...> wrote: > > This will do the job. > char outputstring[32]; > sprintf(outputstring, "%d", integer); > > It basically prints your integer into the character array, as long as > there > is enough space to hold it. This method works both in C and C++. There are > other methods such as stringstream, but they only work in C++. If you're > compiling a C program, for this function to work you need to include > stdio.h > and for C++ it is cstdio. > > Regards > Philip Bennefall > ----- Original Message ----- > From: "Jan Mura" <jan...@vo...> > To: <dev...@li...> > Sent: Monday, May 07, 2007 8:26 AM > Subject: [Dev-C++] Casting of int to string > > > > Hello, > > > > I would like to compare an integer with a string using strcmp(). So I > need > > to cast the int type to string (*char). Is there some commone way how to > > do > > it. Should I use & operator and adress of int in teh function? Or > > something > > else? > > > > Thank you very much > > > > Jan Mura > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > -- <Morpheus> linux, c'est une question de VI ou de MORE |
From: Philip B. <phi...@pb...> - 2007-05-07 06:35:10
|
This will do the job. char outputstring[32]; sprintf(outputstring, "%d", integer); It basically prints your integer into the character array, as long as there is enough space to hold it. This method works both in C and C++. There are other methods such as stringstream, but they only work in C++. If you're compiling a C program, for this function to work you need to include stdio.h and for C++ it is cstdio. Regards Philip Bennefall ----- Original Message ----- From: "Jan Mura" <jan...@vo...> To: <dev...@li...> Sent: Monday, May 07, 2007 8:26 AM Subject: [Dev-C++] Casting of int to string > Hello, > > I would like to compare an integer with a string using strcmp(). So I need > to cast the int type to string (*char). Is there some commone way how to > do > it. Should I use & operator and adress of int in teh function? Or > something > else? > > Thank you very much > > Jan Mura > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Per W. <pw...@ia...> - 2007-05-07 06:34:40
|
You can't cast an int to string, and you cant cast a string to an integer. Either use strtol(), atoi() or similar to convert the string to an integer, or use sprintf() or similar to convert the integer to a string. /pwm On Mon, 7 May 2007, Jan Mura wrote: > Hello, > > I would like to compare an integer with a string using strcmp(). So I need > to cast the int type to string (*char). Is there some commone way how to do > it. Should I use & operator and adress of int in teh function? Or something > else? > > Thank you very much > > Jan Mura > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Jan M. <jan...@vo...> - 2007-05-07 06:26:11
|
Hello, I would like to compare an integer with a string using strcmp(). So I need to cast the int type to string (*char). Is there some commone way how to do it. Should I use & operator and adress of int in teh function? Or something else? Thank you very much Jan Mura |
From: Jonathan W. <jon...@gm...> - 2007-05-07 00:57:10
|
When you create the project you put the code in, you should select the language to use (bottom-right of the dialog) Also, in Project Options > Files, you can change the settings on a file-by-file basis. Happy coding :) Jonathan On 5/7/07, Mux0x55 otto a uno <mu...@gm...> wrote: > > Good evening @ all, > I have a big problem. I want to use DevCpp to compile C progs only, but I > can't compile because it gives me this compilation error: "redeclaration of > built in type bool". How can I solve the problem? Is there a method to > disable c++ compiler ? Help me please. I'm a student of IT Engineering and > I'm using the Roberts library of "Programming with abstractions in C" . > I have to use the devCpp and I have to use these libraries. Help me again. > Thank You. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > -- <Morpheus> linux, c'est une question de VI ou de MORE |
From: Mux0x55 o. a u. <mu...@gm...> - 2007-05-06 22:36:40
|
Good evening @ all, I have a big problem. I want to use DevCpp to compile C progs only, but I can't compile because it gives me this compilation error: "redeclaration of built in type bool". How can I solve the problem? Is there a method to disable c++ compiler ? Help me please. I'm a student of IT Engineering and I'm using the Roberts library of "Programming with abstractions in C" . I have to use the devCpp and I have to use these libraries. Help me again. Thank You. |
From: Michael S. <so...@ea...> - 2007-05-02 22:16:08
|
Per Westermark wrote: >First of all system("") basically starts a new console for running the >command. I'm not sure if you can guarantee that the new environment >inherrits every characteristic from your application. > >Second - the cp variable is not the answer for the chcp command. It is the >return value. In this case, a value of 0 means that the command executed >ok. It corresponds to the value you send to the function exit(), or the >return value when you leave the main() function. > >When you use system() to run a command, that command will emit it's >answers to stdout - i.e. it will print the information. Not return it as >a value for system() to return. > >Go to the Microsoft MSDN web site. They have a complete reference of the >Win32 API. There, you can find a huge amount of functions that you can >call directly from your code. Real functions, producing real answers. >There, you have a lot of information about current locale, code pages etc. > >/pwm > >On Wed, 2 May 2007, Jan Mura wrote: > > > >>Hello, >> >>I would like to ask if there is a way to find out which code page >>iscurrently set for Command Prompt in Windows (I use XP Prof). >> >>I have tried to use somthing like >> >>... >>cp = system("chcp"); >>printf ("%d", cp); >> >> >>But there is always 0 in return value cp. >>The return values should be an implementation defined. So are they >>implemtented in Windows? Did I a mistake? >> >>Thank you. >> >>Jan Mura >>jan...@vo... >> >> >>------------------------------------------------------------------------- >>This SF.net email is sponsored by DB2 Express >>Download DB2 Express C - the FREE version of DB2 express and take >>control of your XML. No limits. Just data. Click to get it now. >>http://sourceforge.net/powerbar/db2/ >>_______________________________________________ >>Dev-cpp-users mailing list >>Dev...@li... >>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> >> >> > > >------------------------------------------------------------------------- >This SF.net email is sponsored by DB2 Express >Download DB2 Express C - the FREE version of DB2 express and take >control of your XML. No limits. Just data. Click to get it now. >http://sourceforge.net/powerbar/db2/ >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > |
From: Michael S. <so...@ea...> - 2007-05-02 22:15:47
|
Per Westermark wrote: >First of all system("") basically starts a new console for running the >command. I'm not sure if you can guarantee that the new environment >inherrits every characteristic from your application. > >Second - the cp variable is not the answer for the chcp command. It is the >return value. In this case, a value of 0 means that the command executed >ok. It corresponds to the value you send to the function exit(), or the >return value when you leave the main() function. > >When you use system() to run a command, that command will emit it's >answers to stdout - i.e. it will print the information. Not return it as >a value for system() to return. > >Go to the Microsoft MSDN web site. They have a complete reference of the >Win32 API. There, you can find a huge amount of functions that you can >call directly from your code. Real functions, producing real answers. >There, you have a lot of information about current locale, code pages etc. > >/pwm > >On Wed, 2 May 2007, Jan Mura wrote: > > > >>Hello, >> >>I would like to ask if there is a way to find out which code page >>iscurrently set for Command Prompt in Windows (I use XP Prof). >> >>I have tried to use somthing like >> >>... >>cp = system("chcp"); >>printf ("%d", cp); >> >> >>But there is always 0 in return value cp. >>The return values should be an implementation defined. So are they >>implemtented in Windows? Did I a mistake? >> >>Thank you. >> >>Jan Mura >>jan...@vo... >> >> >>------------------------------------------------------------------------- >>This SF.net email is sponsored by DB2 Express >>Download DB2 Express C - the FREE version of DB2 express and take >>control of your XML. No limits. Just data. Click to get it now. >>http://sourceforge.net/powerbar/db2/ >>_______________________________________________ >>Dev-cpp-users mailing list >>Dev...@li... >>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> >> >> > > >------------------------------------------------------------------------- >This SF.net email is sponsored by DB2 Express >Download DB2 Express C - the FREE version of DB2 express and take >control of your XML. No limits. Just data. Click to get it now. >http://sourceforge.net/powerbar/db2/ >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > |
From: Jan M. <jan...@vo...> - 2007-05-02 13:36:38
|
Hello, thank you for the hint and the explanation.=20 I will try to find something on MSDN when I will feel ready to visit the = page:-) Jan Mura=20 ----- Original Message -----=20 From: Per Westermark=20 To: Jan Mura=20 Cc: dev...@li...=20 Sent: Wednesday, May 02, 2007 11:29 AM Subject: Re: [Dev-C++] How to find out code page in DOS Command Prompt First of all system("") basically starts a new console for running the command. I'm not sure if you can guarantee that the new environment inherrits every characteristic from your application. Second - the cp variable is not the answer for the chcp command. It is = the return value. In this case, a value of 0 means that the command = executed ok. It corresponds to the value you send to the function exit(), or = the return value when you leave the main() function. When you use system() to run a command, that command will emit it's answers to stdout - i.e. it will print the information. Not return it = as a value for system() to return. Go to the Microsoft MSDN web site. They have a complete reference of = the Win32 API. There, you can find a huge amount of functions that you can call directly from your code. Real functions, producing real answers. There, you have a lot of information about current locale, code pages = etc. /pwm On Wed, 2 May 2007, Jan Mura wrote: > Hello, > > I would like to ask if there is a way to find out which code page > iscurrently set for Command Prompt in Windows (I use XP Prof). > > I have tried to use somthing like > > ... > cp =3D system("chcp"); > printf ("%d", cp); > > > But there is always 0 in return value cp. > The return values should be an implementation defined. So are they > implemtented in Windows? Did I a mistake? > > Thank you. > > Jan Mura > jan...@vo... > > > = -------------------------------------------------------------------------= > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Per W. <pw...@ia...> - 2007-05-02 09:29:46
|
First of all system("") basically starts a new console for running the command. I'm not sure if you can guarantee that the new environment inherrits every characteristic from your application. Second - the cp variable is not the answer for the chcp command. It is the return value. In this case, a value of 0 means that the command executed ok. It corresponds to the value you send to the function exit(), or the return value when you leave the main() function. When you use system() to run a command, that command will emit it's answers to stdout - i.e. it will print the information. Not return it as a value for system() to return. Go to the Microsoft MSDN web site. They have a complete reference of the Win32 API. There, you can find a huge amount of functions that you can call directly from your code. Real functions, producing real answers. There, you have a lot of information about current locale, code pages etc. /pwm On Wed, 2 May 2007, Jan Mura wrote: > Hello, > > I would like to ask if there is a way to find out which code page > iscurrently set for Command Prompt in Windows (I use XP Prof). > > I have tried to use somthing like > > ... > cp = system("chcp"); > printf ("%d", cp); > > > But there is always 0 in return value cp. > The return values should be an implementation defined. So are they > implemtented in Windows? Did I a mistake? > > Thank you. > > Jan Mura > jan...@vo... > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Jan M. <jan...@vo...> - 2007-05-02 09:08:18
|
Hello, I would like to ask if there is a way to find out which code page iscurrently set for Command Prompt in Windows (I use XP Prof). I have tried to use somthing like ... cp = system("chcp"); printf ("%d", cp); But there is always 0 in return value cp. The return values should be an implementation defined. So are they implemtented in Windows? Did I a mistake? Thank you. Jan Mura jan...@vo... |
From: Per W. <pw...@ia...> - 2007-04-29 10:55:51
|
You have to give more information about your problem. What are the exact errror message you get from the linker? What do the link command look like? Note that Dev-C++ normally uses Unix-style naming for libraries, i.e. a library libxx.a is specified as -lxx in the project. /pwm On Sat, 28 Apr 2007 k.a...@at... wrote: > I found source codes for pong which I would love to program. I am using Dev C++ 4.9,9, the program calls for allegro library. I downloaded allegro into my Dev-cpp directory and when I try to compile the source codes my compiler keeps telling me no such file. > > I am new to this group and am a beginner programmer (over time I have used codes for certain things but have never programed anything useful) and new to Dev C++. > > Can someone help me out. > > K.A. Elia |
From: <k.a...@at...> - 2007-04-28 19:04:50
|
I found source codes for pong which I would love to program. I am using Dev C++ 4.9,9, the program calls for allegro library. I downloaded allegro into my Dev-cpp directory and when I try to compile the source codes my compiler keeps telling me no such file. I am new to this group and am a beginner programmer (over time I have used codes for certain things but have never programed anything useful) and new to Dev C++. Can someone help me out. K.A. Elia |
From: Thymian <Th...@gm...> - 2007-04-26 15:00:51
|
Additional to the answer of Per Westermark you could take a look to this Wikipedia article for a better / deeper understanding of the coherences of UTF along with operating systems, editors, e-mails, web, fonts, storage, converters and ... a lot more: http://en.wikipedia.org/wiki/Unicode Gruß, Werner Kitzmann Duong Ha Nguyen schrieb: > Hi Adrian, thank you for answering my question! > > I understand your answer. I tried to do as you said but I don't know > how to type Unicode characters in Dev-C++ IDE. When I typed "ư", it > displayed "?". Can you tell me how to solve it? > > I tried to convert Unicode characters to ANSI using native2ascii.exe > (as I said at my first mail) but the displayed characters were not > what I wanted. I think maybe there was some problems with the fonts. > Can you tell me how to solve it? > > Thanks in advance, > > 2007/4/25, adrian <ad...@la... <mailto:ad...@la...>>: > > Have a nice day, nha...@gm... <mailto:nha...@gm...>! > You, "Duong Ha Nguyen" <mailto:nha...@gm... > <mailto:nha...@gm...>> wrote: > > > >Hello everyone, > >I'm using Dev-C++ 4.9.9.2 <http://4.9.9.2> to write Windows > application. I would like to > >write program using Unicode encoding. I tried to use native2ascii to > >translate Unicode source code to ANSI, but it didn't display > exactly what I > >want. Can someone tell me how to write Windows programs with > Unicode in > >Dev-C++? > >Thanks in advance. > > > > > WinAPI has a two function for straight working with Unicode strings: > - MultiByteToWideChar(...) - for encoding ANSI strings in Unicode, > and > - WideCharToMultiByte(...) - for decoding Unicode to ANSI > > Also you can use TCHAR type for unvisible translating, for example: > > #include <windows.h> > #include <stdio.h> > #ifndef UNICODE > #define UNICODE > ... > TCHAR *s; > scanf ("%s", s); > printf("%s\n", s); > ... > #endif //UNICODE > > if you define UNICODE then > typedef wchar_t TCHAR, > else > typedef char TCHAR; also defined functions, working with this type > (for more see MSDN and tchar.h file) > > > Sincerely, Churin. > > P.S. Excuse me for my bad english - it's not my native language. > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ------------------------------------------------------------------------ > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Per W. <pw...@ia...> - 2007-04-26 14:27:05
|
First of all: 16-bit numbers requires 4 hex characters. 32-bit numbers requires 8 hex characters. 64-bit numbers requires 16 hex characters. Either you are not generating 64-bit numbers, or you are using the wrong with in the formatting string. Second, the MinGW tool uses parts of M$ libraries, i.e. 64-bit numbers are emitted using %I64d/%I64u/%I64x. You are specifying %lX, which represents long integers. For a 32-bit compiler, long is normally also 32-bit (same as int), and to get 64-bit numbers you normally have to write long long, or __int64. Third: For such a trivial set of numbers - only 15000 - duplicates are trivially counted by allocating an array to hold all generated numbers. Then sort the array, and walk through it to count number of instances of each generated value. /pwm On Thu, 26 Apr 2007, Pablo Itaim A. wrote: > Hi, > > I'm working with an application that generate N (1<N<15000) 64 bits numbers in hexadecimal format (%08lX - %08lX) and save it in a .txt file. Some numbers repeats more than ones, so my problem is that i want to know which of the numbers in the file repeats most and how many times. > > Can someboby help me? > > Thank you > > Best regards > > Pablo > |