dev-cpp-users Mailing List for Dev-C++ (Page 408)
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: Khalid El-K. <kha...@ho...> - 2003-04-02 13:38:02
|
Hi fellow, althought it's already explained in a former mail, here it's again struct explode_return explode(char *sep, char *target, int start, int limit) the function is typically taken from the PHP function explode: http://www.php.net/manual/en/function.explode.php except for the start argument which isn't implemented in PHP, and it tells from which index in the string do you want start exploding. hope that helps :-) Regards, Khalid Al-Kary >sorry Khalid, but what is exactly "explode"?. >could you explain a little bit what you are talking about?. > >Ricardo. _________________________________________________________________ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus |
|
From: Ioannis V. <iv...@em...> - 2003-04-02 13:10:47
|
In my hurry I forgot the basics:
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Ioannis Vranos
> Sent: Wednesday, April 02, 2003 2:46 PM
> To: 'Dev-C++'
> Subject: RE: [Dev-C++] itoa - atoi : another implementation
>
>
> My own contribution to this entirely unneded function:
>
> #include <stddef.h>
> #include <stdlib.h>
> #include <stdio.h>
>
>
> char *itoa(int i)
> {
> size_t Length;
> char *p;
> int temp=i;
>
> for(Length=0; temp/=10; Length++)
> ;
>
> p=malloc((Length+1)*sizeof(i));
if(!p)
return NULL;
>
> sprintf(p, "%d", i);
>
> return p;
> }
>
>
>
> Why would anyone need itoa()? With sprinf() one can easily do the
> conversion.
>
>
> sprintf(s,"%d", i);
>
>
> Ioannis Vranos
>
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL: http://run.to/noicys
>
|
|
From: Ioannis V. <iv...@em...> - 2003-04-02 11:46:32
|
My own contribution to this entirely unneded function:
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
char *itoa(int i)
{
size_t Length;
char *p;
int temp=i;
for(Length=0; temp/=10; Length++)
;
p=malloc((Length+1)*sizeof(i));
sprintf(p, "%d", i);
return p;
}
Why would anyone need itoa()? With sprinf() one can easily do the
conversion.
sprintf(s,"%d", i);
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: Ricardo R. <ri...@po...> - 2003-04-02 11:23:38
|
If you are interested in another implementation
of itoa( ) and atoi ( ), here you have the code.
Hope it can be helpful.
Ricardo.
**************ITOA( ) ******************
/* ITOA: Transforms the long n to a string s */
#include <stdio.h>
#include <string.h>
main( )
{
char s[500];
long int n,sign;
int i,j,c;
printf("give me a number to convert:\n");
scanf("%ld",&n);
if((sign=n)<0) /* changing the sign of a negative number */
n=-n;
i=0; /* obtaining the digits of the number */
do{
s[i++]=n%10 + '0';
}while((n/=10)>0);
if(sign<0) /* returning the correct sign */
s[i++]='-';
s[i]='\0'; /* end of the string */
/* reverse (s) */
for(i=0,j=strlen(s)-1 ;i<j ; i++,j--)
{
c=s[i];
s[i]=s[j];
s[j]=c;
}
printf("the result is:\n%s\n",s);
printf("FIN\n");
system("PAUSE");
return 0;
}
************************************
***************** ATOI( ) ***************
/* ATOI: Reading a number as a string s and returning it as a number n */
#include <stdio.h>
main( )
{
char s[100];
long int n; int i;
printf("give a number chain: \n");
gets(s);
printf("your number chain is: %s\n",s);
n=0; /* tranforming s to a number n */
for(i=0;s[i]>='0' && s[i]<='9'; ++i)
n=n*10+(s[i]-'0');
printf("the number is: %ld\n number of digits: %d\n",n,i);
printf("FIN\n");
system("PAUSE");
return 0;
}
************************************
|
|
From: Ioannis V. <iv...@em...> - 2003-04-02 10:48:19
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Luigi Santillo
> Sent: Wednesday, April 02, 2003 9:01 AM
> To: dev...@li...
> Subject: [Dev-C++] itoa - simple implementation [was: integer
> to string]
>
>
> On Wed, Apr 02, 2003 at 04:38:41AM +0200, Per Westermark wrote:
> > Assign of string termination will be one position off, i.e.
> outside your
> > buffer.
> > [..]
>
> Thanks again for pointing out the bug, I'll fix it as shown by the
> few code lines below.
>
> One thing I was wondering is: since "buf" is static, may I assume
> it is filled with '\0' by the compiler? (So there will be ne need
> for me to place the terminating '\0')
>
>
> itoa.c
> ------
> /* .. */
>
> /* old code: #define MAXSZ 21 */
> #define MAXSZ 20 /* assuming integer is made of 19 digits + sign */
>
> char *
> itoa(int n)
> {
> /* old code: static char buf[MAXSZ]; */
> static char buf[MAXSZ + 1];
> char *p = buf + MAXSZ;
> /* ... */
> *p = '\0'; /* << really needed ? >> */
> }
This code is not good. Assume this:
char *p=itoa(9), *q=itoa(10);
I suggest to return a pointer on memory on the free store.
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: Luigi S. <gi...@li...> - 2003-04-02 10:12:40
|
On Wed, Apr 02, 2003 at 04:38:41AM +0200, Per Westermark wrote:
> Assign of string termination will be one position off, i.e. outside your
> buffer.
> [..]
Thanks again for pointing out the bug, I'll fix it as shown by the
few code lines below.
One thing I was wondering is: since "buf" is static, may I assume
it is filled with '\0' by the compiler? (So there will be ne need
for me to place the terminating '\0')
itoa.c
------
/* .. */
/* old code: #define MAXSZ 21 */
#define MAXSZ 20 /* assuming integer is made of 19 digits + sign */
char *
itoa(int n)
{
/* old code: static char buf[MAXSZ]; */
static char buf[MAXSZ + 1];
char *p = buf + MAXSZ;
/* ... */
*p = '\0'; /* << really needed ? >> */
}
------
Regards
--
>> gisan >>
|
|
From: Ricardo R. <ri...@po...> - 2003-04-02 08:32:17
|
sorry Khalid, but what is exactly "explode"?. could you explain a little bit what you are talking about?. Ricardo. |
|
From: Per W. <pw...@ia...> - 2003-04-02 01:39:54
|
Assign of string termination will be one position off, i.e. outside your
buffer.
A buffer[MAXSZ] may only access from 0 to MAXSZ-1 and the pointer is
initialized to p[MAXSZ], i.e. first index outside the buffer.
/Per W
On Tue, 1 Apr 2003, Luigi Santillo wrote:
> Hello,
>
> I've revised the previous implementation of "itoa", adding the
> enhancements that Per Westmark suggested. The code lacks error
> checking, so isn't robust at all.
>
> --
> >> gisan >>
>
>
>
> t_itoa.c
> --------
> #include <stdio.h>
> #include "itoa.h"
>
> int
> main()
> {
> int k = 123; /* integer value to be converted */
> char *s = itoa(k); /* string holding the converted value */
>
> printf("INPUT:\tk = %d\n", k);
> printf("OUTPUT:\ts = %s\n\n", s);
>
> k = -4567; /* a little harder: using a negative number */
> s = itoa(k);
> printf("INPUT:\tk = %d\n", k);
> printf("OUTPUT:\ts = %s\n\n", s);
>
> return 0;
> }
> --------
>
>
> itoa.h
> ------
> #ifndef itoa_h
> #define itoa_h
> #pragma defs_in itoa.c /* needed by makefile generator (ignore it) */
>
> /* turn an integer into a string (i.e. an array) */
> char *
> itoa(int n);
>
> #endif /* not itoa_h */
> ------
>
>
> itoa.c
> ------
> #include "itoa.h"
> #define MAXSZ 21 /* assuming integer is made of 19 digits + sign */
>
> char *
> itoa(int n)
> {
> static char buf[MAXSZ];
> char *p = buf + MAXSZ; /* sweep across buffer */
> char neg = 0; /* 1 means that the integer is negative */
>
> if (n < 0) /* negative integer */
> {
> n = -n; /* work on its absolute value */
> neg = 1; /* turn on the flag */
> }
>
> *p = '\0'; /* terminate string */
>
> while (n && p > buf) /* main loop */
> {
> *--p = '0' + n % 10; /* char for a digit as offset from '0' */
> n /= 10; /* drop last character */
> }
>
> if (neg && p > buf ) /* prepend a negative sign */
> *--p = '-';
>
> return p;
> }
> ------
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ValueWeb:
> Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
> No other company gives more support or power for your dedicated server
> http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> _______________________________________________
> 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: Ioannis V. <iv...@em...> - 2003-04-02 01:24:34
|
My way of reading a sequence with whitespaces without size limit until a
'\n' character is found:
#include <iostream>
#include <string>
int main()
{
using namespace std;
string s;
=20
while(cin)
{
char c;
cin.get(c);
=09
if(c=3D=3D'\n')
break;
s+=3Dc;
}
}
I know it is low level and I assume that there must be a better way =
(which I
do not know so far).
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: Roberto R. <rob...@ar...> - 2003-04-02 00:23:15
|
Hi all, I did a change, using all the mingw with gcc 2.9x and core from dev-cpp 4.9.8 and, voila ! all works well. Some in the translations paths with mingw ... gcc 3.2 has a problem, almost with my XP. Regards Subject: still lost trying to use 4.9.7x or 8. Date: Wed, 26 Mar 2003 22:13:12 -0300 From: rob...@ar... To: 'Dev-C++ -Users-List' <dev...@li...> Hi all, still lost trying to use 4.9.7x or 8. Program skeleton Im use #include #include #include #include #include #include /*#include */ /*#include */ #include /*using namespace std;*/ scanf, fgets, fopen, fclose, fflush, printf ,fprintf, getch, lot of logic ... functions ... mean ... no cout cin cerr ... streams, etc. mean (almost I think) some standard c about 5000 code lines. All of this was comfortable with devcpp 4.9.x.x and gcc 2.9xx (build in from bloodshed) So, Im trying to use new devcpp 4.9.7x or 4.9.8.0 and gcc 3.x (build in from bloodshed) with the same source program, without changes. Need I use #include or #include namespace ... and so on with gcc 3.x ? When I compiling the above source... (without iostream & cstdlib) linker tell me: Compilador: Default compiler Building Makefile: "C:\Dev-Cpp\c\Makefile.win" Ejecutando make clean rm -f myprog.o myprog.exe gcc.exe -c myprog.C -o myprog.o -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/c" -I"c:/Dev-cpp/include/c++" -I"c:/Dev-Cpp/include/c++/mingw32" -I"C:/Dev-Cpp/include/c++/mingw32/bits" myprog.C: In function `int main()': myprog.C:3161: warning: assignment to `int' from `float' (old friend from 4.9.6.x too, nicely) gcc.exe myprog.o -o "myprog.exe" -L"C:/Dev-Cpp/lib" myprog.o(.eh_frame+0x11):myprog.C: undefined reference to `__gxx_personality_v0' make.exe: *** [myprog.exe] Error 1 Ejecución Terminada So I remember Ioannis told me some about ... and change with still the same ... not show more errors, just that. Any ideas ? Im still lost trying to use 4.9.7x or 8. Thanks in advance Roberto |
|
From: Khalid El-K. <kha...@ho...> - 2003-04-01 23:50:41
|
>Hi fellows,
>thank you for helping me to implement explode
>
>here's the fine implementation, with functions formerly implemented
Sorry guys, i Meant "final implementation" not "fine implementation".
>which are required by explode itself, I thought these maybe useful for
>somebody :-) in addition a main method is there for testing explode.
>
>*==================================================*
>
>/*
>* This is a collection of the functions used by
>* explode and explode itself
>* and a main method for trying explode.
>*/
>
>/*
>* since explode orignally returns an array of strings
>* it was better to return a structure that contains a
>* size member which identifies that array's size.
>* explode_return is that structure
>*/
>struct explode_return {
>char **val;
>int size;
>};
>
>/*
>* XString strpos implementation
>* haystack is the search string
>* neddle is the string that will be searched for
>* if neddle = haystack 0 is returned
>* start is the place from where the function will start to check (optional)
>*/
>int strpos(char *haystack, char *neddle, int start)
>{
>if (strcmp(haystack,neddle)==0)
> {
> return 0;
> }
>int nedlen=strlen(neddle);
>int haylen=strlen(haystack);
>
>if (start>haylen-1 || start<0) {
> start=0;
>}
>
>int returned=-1;
>int i=0;
>int br=0;
>for (i=start;i<haylen-nedlen+1;i++)
> {
> if (haystack[i]==neddle[0])
> {
> if (nedlen>1)
> {
> int b;
> for (b=i+1;b<nedlen+i;b++)
> {
> if (haystack[b]!=neddle[b-i])
> {
> break;
> }
> if (haystack[b]==neddle[b-i] && b==nedlen+i-1)
> {
> returned=i;
> br=1;
> break;
> }
> }
> }
> else
> {
> returned=i;
> br=1;
> break;
> }
> }
> if (br==1)
> break;
> }
>return returned;
>}
>/*
>* XString substr implementation
>* target is the string that we will cut from
>* start is the cut starting position
>* length is the place where we will finish the cut
>*/
>char *substr(char *target, int start, int length)
>{
> if (start<0) {
> start=0;
> }
>
> if (length>strlen(target)-start) {
> length=strlen(target)-start;
> }
>
> int i=0;
> char *temp=(char *) malloc(length*sizeof(char));
>
> for (i=start;i<length+start;i++) {
> temp[i-start]=target[i];
> }
>
> return temp;
>}
>/*
>* XString explode implementation
>* sep is the separator string
>* target is the string that will be exploded
>* start is the index from which you want to start exploding
>* limit is the number of elements returned (-1 = unlimited)
>*/
>struct explode_return explode(char *sep, char *target, int start, int
>limit) {
>/* calculate the length of strings */
>int seplen=strlen(sep);
>int tarlen=strlen(target);
>
>/* make the initial vars */
>char **temp;
>int num_occ=0;
>int f_start=0;
>int cutlen;
>start-=seplen;
>
>/* the main loop */
>while ((start=strpos(target,sep,start+seplen))!=-1 && f_start<tarlen &&
>(num_occ<limit || limit==-1)) {
> char *cut=substr(target,f_start,start-f_start);
> f_start=start+seplen;
> cutlen=strlen(cut);
>
> if (cutlen==0) {
> continue;
> }
> temp = (char **) realloc((num_occ>0) ? (temp) :
>(0),(num_occ+1)*sizeof(char*));
> temp[num_occ]=(char*) malloc(cutlen*sizeof(char));
> strcpy(temp[num_occ],cut);
> num_occ++;
> free(cut);
>}
>
>if (f_start<tarlen) {
> temp = (char **) realloc((num_occ>0) ? (temp) :
>(0),(num_occ+1)*sizeof(char*));
> temp[num_occ]=substr(target,f_start,tarlen-f_start);
> num_occ++;
> }
>
>struct explode_return returned;
>returned.val=temp;
>returned.size=num_occ;
>
>return returned;
>}
>
>/* this is a main for trying explode */
>int main() {
>struct explode_return f=explode(",","h,h,,h,h,j,u,o,p,ye",0,-1);
>int i;
>for (i=0;i<f.size;i++) {
> printf("%s\n",f.val[i]);
> free(f.val[i]);
>}
>
>free(f.val);
>return 0;
>}
>*==================================================*
>
>Regards,
>Khalid Al-Kary.
>
>
>_________________________________________________________________
>Add photos to your e-mail with MSN 8. Get 2 months FREE*.
>http://join.msn.com/?page=features/featuredemail
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: ValueWeb: Dedicated Hosting for just
>$79/mo with 500 GB of bandwidth! No other company gives more support or
>power for your dedicated server
>http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
>_______________________________________________
>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
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
|
|
From: Luigi S. <gi...@li...> - 2003-04-01 21:59:51
|
Hello,
I've revised the previous implementation of "itoa", adding the
enhancements that Per Westmark suggested. The code lacks error
checking, so isn't robust at all.
--
>> gisan >>
t_itoa.c
--------
#include <stdio.h>
#include "itoa.h"
int
main()
{
int k = 123; /* integer value to be converted */
char *s = itoa(k); /* string holding the converted value */
printf("INPUT:\tk = %d\n", k);
printf("OUTPUT:\ts = %s\n\n", s);
k = -4567; /* a little harder: using a negative number */
s = itoa(k);
printf("INPUT:\tk = %d\n", k);
printf("OUTPUT:\ts = %s\n\n", s);
return 0;
}
--------
itoa.h
------
#ifndef itoa_h
#define itoa_h
#pragma defs_in itoa.c /* needed by makefile generator (ignore it) */
/* turn an integer into a string (i.e. an array) */
char *
itoa(int n);
#endif /* not itoa_h */
------
itoa.c
------
#include "itoa.h"
#define MAXSZ 21 /* assuming integer is made of 19 digits + sign */
char *
itoa(int n)
{
static char buf[MAXSZ];
char *p = buf + MAXSZ; /* sweep across buffer */
char neg = 0; /* 1 means that the integer is negative */
if (n < 0) /* negative integer */
{
n = -n; /* work on its absolute value */
neg = 1; /* turn on the flag */
}
*p = '\0'; /* terminate string */
while (n && p > buf) /* main loop */
{
*--p = '0' + n % 10; /* char for a digit as offset from '0' */
n /= 10; /* drop last character */
}
if (neg && p > buf ) /* prepend a negative sign */
*--p = '-';
return p;
}
------
|
|
From: Defiant H. <he...@er...> - 2003-04-01 20:39:34
|
What can cause a segmentation fault besides pointers? I've been getting=20 one that resists all attempts to track down its cause. The problem persisted after I eliminated all pointers to the variable tha= t=20 seems to be causing it. (I made the function return the value instead of=20 modifying it directly) There is some recursion involved, but as far as I can tell, it isn=E2=80=99= t being=20 called before the fault. I have determined that the memory location of this variable /is/ being=20 changed before the crash. However, when I attempted to locate exactly whe= re=20 in the code it is being changed using printf(%p,foo), the crash didn=E2=80= =99t=20 happen. (Heisenburg meets Ritchie?) The fault seems like it might be dependent on the contents of a file I=E2= =80=99m=20 viewing (ASCII text). Some files can be read without crashing; others=20 cannot. Other than that, I have no clue. |
|
From: Khalid El-K. <kha...@ho...> - 2003-04-01 20:29:25
|
Hi fellows,
thank you for helping me to implement explode
here's the fine implementation, with functions formerly implemented which
are required by explode itself, I thought these maybe useful for somebody
:-) in addition a main method is there for testing explode.
*==================================================*
/*
* This is a collection of the functions used by
* explode and explode itself
* and a main method for trying explode.
*/
/*
* since explode orignally returns an array of strings
* it was better to return a structure that contains a
* size member which identifies that array's size.
* explode_return is that structure
*/
struct explode_return {
char **val;
int size;
};
/*
* XString strpos implementation
* haystack is the search string
* neddle is the string that will be searched for
* if neddle = haystack 0 is returned
* start is the place from where the function will start to check (optional)
*/
int strpos(char *haystack, char *neddle, int start)
{
if (strcmp(haystack,neddle)==0)
{
return 0;
}
int nedlen=strlen(neddle);
int haylen=strlen(haystack);
if (start>haylen-1 || start<0) {
start=0;
}
int returned=-1;
int i=0;
int br=0;
for (i=start;i<haylen-nedlen+1;i++)
{
if (haystack[i]==neddle[0])
{
if (nedlen>1)
{
int b;
for (b=i+1;b<nedlen+i;b++)
{
if (haystack[b]!=neddle[b-i])
{
break;
}
if (haystack[b]==neddle[b-i] && b==nedlen+i-1)
{
returned=i;
br=1;
break;
}
}
}
else
{
returned=i;
br=1;
break;
}
}
if (br==1)
break;
}
return returned;
}
/*
* XString substr implementation
* target is the string that we will cut from
* start is the cut starting position
* length is the place where we will finish the cut
*/
char *substr(char *target, int start, int length)
{
if (start<0) {
start=0;
}
if (length>strlen(target)-start) {
length=strlen(target)-start;
}
int i=0;
char *temp=(char *) malloc(length*sizeof(char));
for (i=start;i<length+start;i++) {
temp[i-start]=target[i];
}
return temp;
}
/*
* XString explode implementation
* sep is the separator string
* target is the string that will be exploded
* start is the index from which you want to start exploding
* limit is the number of elements returned (-1 = unlimited)
*/
struct explode_return explode(char *sep, char *target, int start, int limit)
{
/* calculate the length of strings */
int seplen=strlen(sep);
int tarlen=strlen(target);
/* make the initial vars */
char **temp;
int num_occ=0;
int f_start=0;
int cutlen;
start-=seplen;
/* the main loop */
while ((start=strpos(target,sep,start+seplen))!=-1 && f_start<tarlen &&
(num_occ<limit || limit==-1)) {
char *cut=substr(target,f_start,start-f_start);
f_start=start+seplen;
cutlen=strlen(cut);
if (cutlen==0) {
continue;
}
temp = (char **) realloc((num_occ>0) ? (temp) :
(0),(num_occ+1)*sizeof(char*));
temp[num_occ]=(char*) malloc(cutlen*sizeof(char));
strcpy(temp[num_occ],cut);
num_occ++;
free(cut);
}
if (f_start<tarlen) {
temp = (char **) realloc((num_occ>0) ? (temp) :
(0),(num_occ+1)*sizeof(char*));
temp[num_occ]=substr(target,f_start,tarlen-f_start);
num_occ++;
}
struct explode_return returned;
returned.val=temp;
returned.size=num_occ;
return returned;
}
/* this is a main for trying explode */
int main() {
struct explode_return f=explode(",","h,h,,h,h,j,u,o,p,ye",0,-1);
int i;
for (i=0;i<f.size;i++) {
printf("%s\n",f.val[i]);
free(f.val[i]);
}
free(f.val);
return 0;
}
*==================================================*
Regards,
Khalid Al-Kary.
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
|
|
From: joric <sk...@ho...> - 2003-04-01 18:14:33
|
on every code a compile and run a get a error (unrecognized option = '-fdollar-in-identfiers') what can a do tho let my programs work ? pleas = send me back |
|
From: Ken B. <ke...@al...> - 2003-04-01 16:43:34
|
Ah, my mistake. I see that now; didn't look far enough. Ken Bradford Alpha II Service, Inc. > -----Original Message----- > From: Per Westermark [mailto:pw...@ia...] > Sent: Tuesday, April 01, 2003 12:33 PM > To: Ricardo L=F3pez Ruiz > Cc: ke...@al...; Dev-C++ > Subject: Re: [Dev-C++] integer to string > > > They are equivalent in one more way - they are not standard. > > /Per W > > On Tue, 1 Apr 2003, Ricardo L=F3pez Ruiz wrote: > > > perhaps both functions, itoa( ) and ltoa( ), are equivalent > > in our case (Dev-cpp), because the "int" variables are > > "long int" by default (4 bytes). > > > > Ricardo. > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: ValueWeb: > > Dedicated Hosting for just $79/mo with 500 GB of bandwidth! > > No other company gives more support or power for your dedicated serve= r > > http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > |
|
From: Per W. <pw...@ia...> - 2003-04-01 16:34:48
|
They are equivalent in one more way - they are not standard. /Per W On Tue, 1 Apr 2003, Ricardo L=F3pez Ruiz wrote: > perhaps both functions, itoa( ) and ltoa( ), are equivalent > in our case (Dev-cpp), because the "int" variables are > "long int" by default (4 bytes). > > Ricardo. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: ValueWeb: > Dedicated Hosting for just $79/mo with 500 GB of bandwidth! > No other company gives more support or power for your dedicated server > http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ > _______________________________________________ > 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: Ricardo R. <ri...@po...> - 2003-04-01 15:53:22
|
perhaps both functions, itoa( ) and ltoa( ), are equivalent in our case (Dev-cpp), because the "int" variables are "long int" by default (4 bytes). Ricardo. |
|
From: philipmortimer <ph...@co...> - 2003-04-01 14:51:37
|
const int LEN = 80;
char str[LEN];
cout << "Enter string: " << flush;
cin.getline(str, LEN); // use default '\n' delimeter
cout << str << endl;
In the above example getline will just keep reading in characters
(whether they are tabs, spaces or anything else) until:
1) LEN - 1 characters have been read
2) it encounters the delimeter specified by the 3rd argument (which
defaults to the newline character)
3) it reaches the end of the file
whichever happens first (typically encountering a newline) - see
http://www.objsw.com/docs/iostream_19.html#SEC19
Philip Mortimer
----- Original Message -----
From: <pr...@le...>
To: <tel...@ya...>
Cc: <dev...@li...>
Sent: Tuesday, April 01, 2003 11:57 AM
Subject: Re: [Dev-C++] Spaces in strings?
>
> Thanks Richard.
> But I don't understand how the input stream being used by getline() (i.e.
> cin) reads in spaces and tabs. Any explanations on that?
>
> <code snippet>
> std::getline(std::cin, name);
> </code snippet>
>
>
> Regards,
> Pranav Negandhi
>
> This email is a natural product. The slight variations in spelling and
> grammar enhance its individual character and beauty and are in no
> way considered to be flaws or defects.
>
>
>
> <snip>
>
> yeah, you've gotten a few emails telling you to uses the getline function
> rather tham cin.
> basically cin will read the input string up to the first white space, this
> is either a space(" ")or a tab(" ") or a enter( "/n" )
> getline however will read everything including spaces and tabs up to the
> first 'enter' or "endl"
> <snip>
>
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ValueWeb:
> Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
> No other company gives more support or power for your dedicated server
> http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> _______________________________________________
> 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: Ken B. <ke...@al...> - 2003-04-01 14:31:51
|
Perhaps you mean LTOA? As in:
char * ltoa ( long value, char * buffer, int radix );
Ken Bradford
Alpha II Service, Inc.
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of Ricardo
> L=F3pez Ruiz
> Sent: Tuesday, April 01, 2003 3:50 AM
> To: Khalid El-Kary; Dev-C++
> Subject: Re: [Dev-C++] integer to string
>
>
> perhaps this example can help you a little more.
> Ricardo.
>
>
> **********ITOA/ATOI **********
>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main()
> {
> char cad[20];
>
> /* the transformation: integer --> string */
> itoa(2003,cad,10); // 2003 is the number to store in cad[]
> printf(cad); // in decimal base =3D 10.
>
> /* and the inverse transformation: string --> integer */
> printf("\n %d",atoi(cad)); // cad[ ] is transformed to integer
>
> printf("\n\n");
> system("PAUSE");
> return 0;
> }
>
> *************************************
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ValueWeb:
> Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
> No other company gives more support or power for your dedicated server
> http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Per W. <pw...@ia...> - 2003-04-01 14:30:02
|
free() ignores the contents of your array. All you need is the pointer you originally received from malloc() or calloc(). free() will then release the full block - unless you for some reason has managed to break the heap by writing outside of the allocated area (or actually to write immediately BEFORE the returned pointer) and thereby destroy the heap management that is almost always part of the allocated memory block. /Per W On Tue, 1 Apr 2003, Luigi Santillo wrote: > On Tue, Apr 01, 2003 at 11:37:28AM +0200, Per Westermark wrote: > > Your implementation of itoa would leak memory - normally itoa would use a > > static buffer that is overwritten at each call. > > I agree that mine is just a try, also I wish to learn from your > comment. My code has a memory leak because of: > - user will almost always forget to call "free" (shortly: bad designed code) > - there is a bug in the code (shortly: bugged code) > - both bad design and bad code > > By the way, a call to "strcpy" does copy the piece of an array up-to > the '\0', does the function "free" return memory up-to the '\0' or does > it free the whole array (as I assume) ? > > > > A better itoa would build the buffer from the end, i.e. *p-- = ch > > thereby removing need for reversing the string. > > I'll try to follow this advice too. > > > /Per W > > Thanks Per > -- > >> gisan >> > > > ------------------------------------------------------- > This SF.net email is sponsored by: ValueWeb: > Dedicated Hosting for just $79/mo with 500 GB of bandwidth! > No other company gives more support or power for your dedicated server > http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ > _______________________________________________ > 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: Robert E. <ro...@pe...> - 2003-04-01 14:28:48
|
Hello It seems like the CVS support is broken. I'm using cvs.exe 1.11.5 from cvshome.org and it works perfectly in command-line, but not in Dev-C++. Could someone developer please look this up as this is a pretty important function to some people like me :) Best regards, Robert Eriksson > > Hello > > > I remember of some messages about using CVS on Dev-C++, but I don't > remember any useful answer; the mailing list search on SourceForge isn'= t > working. So, here are my question: > > 1. Does the CVS functionality even works? > 2. Does it works on SF's CVS? > 3. If the 'cvs.exe' that I got from http://www.cvshome.org is the only > one that doesn't work with Dev-C++, where can I get one that works? > (Using just command-line, it also doesn't work) > > > > I'm using Win98 SE, and CVS 1.11.5 > > > > > > Daniel K. O. > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: ValueWeb: > Dedicated Hosting for just $79/mo with 500 GB of bandwidth! > No other company gives more support or power for your dedicated server > http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ > _______________________________________________ > 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: philip m. <mor...@ho...> - 2003-04-01 14:14:07
|
const int LEN = 80;
char str[LEN];
cout << "Enter string: " << flush;
cin.getline(str, LEN); // use default '\n' delimeter
cout << str << endl;
In the above example getline will just keep reading in characters
(whether they are tabs, spaces or anything else) until:
1) LEN - 1 characters have been read
2) it encounters the delimeter specified by the 3rd argument (which
defaults to the newline character)
3) it reaches the end of the file
whichever happens first - see
http://www.objsw.com/docs/iostream_19.html#SEC19
Philip Mortimer
----- Original Message -----
From: <pr...@le...>
To: <tel...@ya...>
Cc: <dev...@li...>
Sent: Tuesday, April 01, 2003 11:57 AM
Subject: Re: [Dev-C++] Spaces in strings?
>
> Thanks Richard.
> But I don't understand how the input stream being used by getline() (i.e.
> cin) reads in spaces and tabs. Any explanations on that?
>
> <code snippet>
> std::getline(std::cin, name);
> </code snippet>
>
>
> Regards,
> Pranav Negandhi
>
> This email is a natural product. The slight variations in spelling and
> grammar enhance its individual character and beauty and are in no
> way considered to be flaws or defects.
>
>
>
> <snip>
>
> yeah, you've gotten a few emails telling you to uses the getline function
> rather tham cin.
> basically cin will read the input string up to the first white space, this
> is either a space(" ")or a tab(" ") or a enter( "/n" )
> getline however will read everything including spaces and tabs up to the
> first 'enter' or "endl"
> <snip>
>
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ValueWeb:
> Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
> No other company gives more support or power for your dedicated server
> http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> _______________________________________________
> 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: Luigi S. <gi...@li...> - 2003-04-01 14:10:09
|
On Tue, Apr 01, 2003 at 11:37:28AM +0200, Per Westermark wrote: > Your implementation of itoa would leak memory - normally itoa would use a > static buffer that is overwritten at each call. I agree that mine is just a try, also I wish to learn from your comment. My code has a memory leak because of: - user will almost always forget to call "free" (shortly: bad designed code) - there is a bug in the code (shortly: bugged code) - both bad design and bad code By the way, a call to "strcpy" does copy the piece of an array up-to the '\0', does the function "free" return memory up-to the '\0' or does it free the whole array (as I assume) ? > > A better itoa would build the buffer from the end, i.e. *p-- = ch > thereby removing need for reversing the string. I'll try to follow this advice too. > /Per W Thanks Per -- >> gisan >> |
|
From: Reid T. <Rei...@at...> - 2003-04-01 12:43:41
|
char buf[99];
int five =3D 5;
sprintf(buf, "%d", five);
printf(" this is five [%s]\n", buf);
--
thanks,
reid
-----Original Message-----
From: Per Westermark [mailto:pw...@ia...]=20
Sent: Tuesday, April 01, 2003 5:12 AM
To: Ricardo L=F3pez Ruiz
Cc: Khalid El-Kary; Dev-C++
Subject: Re: [Dev-C++] integer to string
Note that while itoa is nonstandard, some implementations take two =
parameters, and some take 3.
The third parameter is then number base, i.e. 2 for binary, 8 for octal, =
etc.
/Per W
On Tue, 1 Apr 2003, Ricardo L=F3pez Ruiz wrote:
> perhaps this example can help you a little more.
> Ricardo.
>
>
> **********ITOA/ATOI **********
>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main()
> {
> char cad[20];
>
> /* the transformation: integer --> string */
> itoa(2003,cad,10); // 2003 is the number to store in cad[]
> printf(cad); // in decimal base =3D 10.
>
> /* and the inverse transformation: string --> integer */
> printf("\n %d",atoi(cad)); // cad[ ] is transformed to =
integer
>
> printf("\n\n");
> system("PAUSE");
> return 0;
> }
>
> *************************************
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ValueWeb:
> Dedicated Hosting for just $79/mo with 500 GB of bandwidth! No other=20
> company gives more support or power for your dedicated server=20
> http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> _______________________________________________
> 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
>
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb:=20
Dedicated Hosting for just $79/mo with 500 GB of bandwidth!=20
No other company gives more support or power for your dedicated server =
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
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
|