dev-cpp-users Mailing List for Dev-C++ (Page 657)
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: Jason H. <jas...@bt...> - 2001-10-20 02:16:30
|
As defined in C/C++ Programmers Reference: strcat ------ #include <string.h> char *strcat(char *str1, const char *str2); The strcat() function concatenates a copy of str2 to str1 and terminates str1 with a null. The null terminator originally ending str1 is overwritten by the first character of str2. The string str2 is untouched by the operation. If the arrays overlap, the behavior of strcat() is undefined. In C99, str1 and str2 are qualified by restrict. The strcat() function returns str1. Remember, no bounds checking takes place, so it is the programmer's responsibility to ensure that str1 is large enough to hold both its original contents and also those of str2. ------------------------ The function strcat() is defined in the C, and therefore the C++, standard. It must follow a consistent behaviour. It is feasible that it could have been written in assembler, but it will still have the same basic behaviour. I know it would be slow in large strings, but there isn't really any faster and reliable way to search for the null. Skipping characters opens up the possibility of missing the proper null, and accessing characters after it which will be undefined. In strcat you might not overrun the array containing the string that way, but in a similar function such as strlen you probably would, and that would be an access violation. Without more information about the string being passed then you are pretty much limited to going throught the string from start to finish. Generally if a programmer was dealing with very large string then it would be wise for him/her to find a better way of dealing with them (such as tracking the length), or to just accept the performance hit. Whether the include is an on/off switch or a header won't change the way the function works, just how the compiler adds it to the exe. Regards, Jason. PS: Yet again I've probably gone OTT (Over The Top). LOL! It looks like I've written an essay on a standard function. PPS: Why is it us to always seem to be arguing over silly little things like this? |
|
From: Jason H. <jas...@bt...> - 2001-10-20 01:47:57
|
Hi, to sum it all up... you haven't performed any operations on the rational
objects p, s, t, & f. They still have the values they were initialised with,
which was zero. You will need to do the relavant ops on each i.e. p = add(a,
b);
I've created a header and cpp file from the code you supplied and added the
relevant bits. I've also slightly changed some of the definitions to make
them follow a what I think would be a slightly better approach. All I've
done is inlined some of the methods of rational, and added const to the
methods that won't change any of the values of the object. This is wise as
it helps prevent possible errors if you modify those methods in future.
I have also added some comments to where I think you need to take a look at
what you are trying to do (the reduce method). I hope they are useful to
you.
Regards, Jason.
----- Original Message -----
From: "chromatonus 712" <chr...@ho...>
To: <dev...@li...>
Sent: Saturday, October 20, 2001 12:52 AM
Subject: [Dev-C++] PLEASE HELP: a prgm not working
> hi, this program is supposed to add, subtract, multiply and divide two
> fractions and simplify the answers, using class objects. But the prgm
> displays 0/0 for the sums, differences, etc. How can I fix this program?
> THank you for your time :)
>
>
> #include <iostream.h>
> #include <conio.h>
> #include <stdlib.h>
>
>
> //=============================== CLASS HEADER
> ===============================
>
> class rational
> {
> public:
> // constructors
> rational();
> rational( int n, int d );
> // accessors
> int get_numerator();
> int get_denominator();
> // modifiers
> void change_numerator(int n);
> void change_denominator(int d);
> // enter from keyboard
> void enter();
> // precondition: two numbers are sent in for each rational
> number
> // postcondition: they are stored as two rational numbers
> // display
> void display();
>
> void reduce(int pn, int pd, int sn, int sd, int tn, int td,
int
> fn, int fd);
> // precondition: send in rational @n/@d (@ meaning an operation)
> // postcondition: calculate d = gcd(@n,@d)
> // reset @n = @n/d and @d = @d/d
>
> private:
> int my_numerator,my_denominator;
> };
>
> //============================FREE FUNCTIONS
> ==================================
>
> // assignment operator
> void assign( rational a , rational &b );
> // precondition: rational number a is sent in
> // postcondition: b = a
> // bn = an and bd = ad
>
> // comparison operator
> bool are_equal( rational a, rational b);
> // precondition: rational numbers a and b are sent in
> // postcondition: returns true if a = b else returns false
> // a = b iff an*bd = ad*bn
>
> // add rational numbers
> rational add( rational a, rational b );
> // precondition: send in rational numbers a,b where
> // b != 0
> // postcondition: calculate c = a + b by:
> // a = an/ad b = bn/bd
> // cn = an*bd + ad*bn
> // cd = ad*bd
> // reduce to lowest terms
> // subtract
> rational subt(rational, rational b);
>
> // multiply rationals
> rational mult( rational a, rational b);
> // precondition: b != 0
> // postcondition: calculate c = a*b by:
> // cn = an * bn
> // cd = ad * bd
> // reduce to lowest terms
>
> // divide rationals
> rational div(rational a, rational b);
> // precondition: b !=0
> // postcondition: calculate c = a/b by:
> // cn = an * bd
> // cd = ad * bn
> // reduce to lowest terms
>
>
>
>
//===============================IMPLEMENTATION=============================
===
> rational::rational()
> {
> my_numerator = 0;
> my_denominator = 0;
> }
> void rational::enter()
> {
> cout<< "A rational (numerator first)= " << "\n" << "\n";
> cin>> my_numerator;
> cin>> my_denominator;
> cout<< "\n";
> }
> void rational::change_numerator(int n)
> {
> my_numerator = n;
> }
> void rational::change_denominator(int d)
> {
> my_denominator = d;
> }
> int rational::get_numerator()
> {
> return (my_numerator);
> }
> int rational::get_denominator()
> {
> return (my_denominator);
> }
>
> rational::rational(int n, int d)
> {
> my_numerator = n;
> my_denominator = d;
> }
>
> //===============================CLIENT
> PROGRAM================================
>
> int main()
> {
> rational a,
> b,
> p,
> s,
> t,
> f;
> a.enter();
> b.enter();
> cout<< "\n";
> a.display();
> b.display();
> cout<< "\n" << "\n";
> cout<< "Sum= " << "\n";
> p.display();
> cout<< "Difference= " << "\n";
> s.display();
> cout<< "Product= " << "\n";
> t.display();
> cout<< "Quotient= " << "\n";
> f.display();
> }
>
> bool are_equal(rational a, rational b)
> {
> int an = a.get_numerator(),
> ad = a.get_denominator(),
> bn = b.get_numerator(),
> bd = b.get_denominator();
> if (an * bd == ad * bn)
> return( true );
> else
> return( false );
> }
>
> rational add(rational a, rational b)
> {
> int an = a.get_numerator(),
> ad = a.get_denominator(),
> bn = b.get_numerator(),
> bd = b.get_denominator(),
> pn = an * bd + bn * ad,
> pd = ad * bd;
> rational p(pn, pd);
> return p;
> }
>
> rational subt(rational a, rational b)
> {
> int an = a.get_numerator(),
> ad = a.get_denominator(),
> bn = b.get_numerator(),
> bd = b.get_denominator(),
> sn = an * bd - bn * ad,
> sd = ad * bd;
> rational s(sn, sd);
> return s;
> }
>
> rational mult(rational a, rational b)
> {
> int an = a.get_numerator(),
> ad = a.get_denominator(),
> bn = b.get_numerator(),
> bd = b.get_denominator(),
> tn = an * bn,
> td = ad * bd;
> rational t(tn, td);
> return t;
> }
>
> rational div(rational a, rational b)
> {
> int an = a.get_numerator(),
> ad = a.get_denominator(),
> bn = b.get_denominator(),
> bd = b.get_numerator(),
> fn = an * bn,
> fd = ad * bd;
> rational f(fn, fd);
> return f;
> }
>
> void rational::reduce(int pn, int pd, int sn, int sd, int tn, int td, int
> fn, int fd)
> {
> int j, d;
> if( pd >= pn)
> j = pn;
> else
> j = pd;
> for( d = j; d>0; d--)
> {
> if( pn%d ==0 && pd%d ==0)
> {
> pn = pn/d;
> pd = pd/d;
> }
> }
> if( sd >= sn)
> j = sn;
> else
> j = sd;
> for( d = j; d>0; d--)
> {
> if( sn%d ==0 && sd%d ==0)
> {
> sn = sn/d;
> sd = sd/d;
> }
> }
> if( td >= tn)
> j = tn;
> else
> j = td;
> for( d = j; d>0; d--)
> {
> if( tn%d ==0 && td%d ==0)
> {
> tn = tn/d;
> td = td/d;
> }
> }
> if( fd >= fn)
> j = fn;
> else
> j = fd;
> for( d = j; d>0; d--)
> {
> if( fn%d ==0 && fd%d ==0)
> {
> fn = fn/d;
> fd = fd/d;
> }
> }
> }
>
> void rational::display()
> {
> cout<< my_numerator << "/" << my_denominator << "\n";
> system("PAUSE");
> }
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: chromatonus 7. <chr...@ho...> - 2001-10-19 23:52:15
|
hi, this program is supposed to add, subtract, multiply and divide two
fractions and simplify the answers, using class objects. But the prgm
displays 0/0 for the sums, differences, etc. How can I fix this program?
THank you for your time :)
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
//=============================== CLASS HEADER
===============================
class rational
{
public:
// constructors
rational();
rational( int n, int d );
// accessors
int get_numerator();
int get_denominator();
// modifiers
void change_numerator(int n);
void change_denominator(int d);
// enter from keyboard
void enter();
// precondition: two numbers are sent in for each rational
number
// postcondition: they are stored as two rational numbers
// display
void display();
void reduce(int pn, int pd, int sn, int sd, int tn, int td, int
fn, int fd);
// precondition: send in rational @n/@d (@ meaning an operation)
// postcondition: calculate d = gcd(@n,@d)
// reset @n = @n/d and @d = @d/d
private:
int my_numerator,my_denominator;
};
//============================FREE FUNCTIONS
==================================
// assignment operator
void assign( rational a , rational &b );
// precondition: rational number a is sent in
// postcondition: b = a
// bn = an and bd = ad
// comparison operator
bool are_equal( rational a, rational b);
// precondition: rational numbers a and b are sent in
// postcondition: returns true if a = b else returns false
// a = b iff an*bd = ad*bn
// add rational numbers
rational add( rational a, rational b );
// precondition: send in rational numbers a,b where
// b != 0
// postcondition: calculate c = a + b by:
// a = an/ad b = bn/bd
// cn = an*bd + ad*bn
// cd = ad*bd
// reduce to lowest terms
// subtract
rational subt(rational, rational b);
// multiply rationals
rational mult( rational a, rational b);
// precondition: b != 0
// postcondition: calculate c = a*b by:
// cn = an * bn
// cd = ad * bd
// reduce to lowest terms
// divide rationals
rational div(rational a, rational b);
// precondition: b !=0
// postcondition: calculate c = a/b by:
// cn = an * bd
// cd = ad * bn
// reduce to lowest terms
//===============================IMPLEMENTATION================================
rational::rational()
{
my_numerator = 0;
my_denominator = 0;
}
void rational::enter()
{
cout<< "A rational (numerator first)= " << "\n" << "\n";
cin>> my_numerator;
cin>> my_denominator;
cout<< "\n";
}
void rational::change_numerator(int n)
{
my_numerator = n;
}
void rational::change_denominator(int d)
{
my_denominator = d;
}
int rational::get_numerator()
{
return (my_numerator);
}
int rational::get_denominator()
{
return (my_denominator);
}
rational::rational(int n, int d)
{
my_numerator = n;
my_denominator = d;
}
//===============================CLIENT
PROGRAM================================
int main()
{
rational a,
b,
p,
s,
t,
f;
a.enter();
b.enter();
cout<< "\n";
a.display();
b.display();
cout<< "\n" << "\n";
cout<< "Sum= " << "\n";
p.display();
cout<< "Difference= " << "\n";
s.display();
cout<< "Product= " << "\n";
t.display();
cout<< "Quotient= " << "\n";
f.display();
}
bool are_equal(rational a, rational b)
{
int an = a.get_numerator(),
ad = a.get_denominator(),
bn = b.get_numerator(),
bd = b.get_denominator();
if (an * bd == ad * bn)
return( true );
else
return( false );
}
rational add(rational a, rational b)
{
int an = a.get_numerator(),
ad = a.get_denominator(),
bn = b.get_numerator(),
bd = b.get_denominator(),
pn = an * bd + bn * ad,
pd = ad * bd;
rational p(pn, pd);
return p;
}
rational subt(rational a, rational b)
{
int an = a.get_numerator(),
ad = a.get_denominator(),
bn = b.get_numerator(),
bd = b.get_denominator(),
sn = an * bd - bn * ad,
sd = ad * bd;
rational s(sn, sd);
return s;
}
rational mult(rational a, rational b)
{
int an = a.get_numerator(),
ad = a.get_denominator(),
bn = b.get_numerator(),
bd = b.get_denominator(),
tn = an * bn,
td = ad * bd;
rational t(tn, td);
return t;
}
rational div(rational a, rational b)
{
int an = a.get_numerator(),
ad = a.get_denominator(),
bn = b.get_denominator(),
bd = b.get_numerator(),
fn = an * bn,
fd = ad * bd;
rational f(fn, fd);
return f;
}
void rational::reduce(int pn, int pd, int sn, int sd, int tn, int td, int
fn, int fd)
{
int j, d;
if( pd >= pn)
j = pn;
else
j = pd;
for( d = j; d>0; d--)
{
if( pn%d ==0 && pd%d ==0)
{
pn = pn/d;
pd = pd/d;
}
}
if( sd >= sn)
j = sn;
else
j = sd;
for( d = j; d>0; d--)
{
if( sn%d ==0 && sd%d ==0)
{
sn = sn/d;
sd = sd/d;
}
}
if( td >= tn)
j = tn;
else
j = td;
for( d = j; d>0; d--)
{
if( tn%d ==0 && td%d ==0)
{
tn = tn/d;
td = td/d;
}
}
if( fd >= fn)
j = fn;
else
j = fd;
for( d = j; d>0; d--)
{
if( fn%d ==0 && fd%d ==0)
{
fn = fn/d;
fd = fd/d;
}
}
}
void rational::display()
{
cout<< my_numerator << "/" << my_denominator << "\n";
system("PAUSE");
}
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|
|
From: Daniel G. <sp...@ho...> - 2001-10-19 17:07:16
|
<html><div style='background-color:'><DIV> <P>Bugger me, I haven't a clue lmao!!!<BR><BR></P></DIV> <DIV></DIV> <DIV></DIV>>From: "kmk" <KM...@WO...> <DIV></DIV>>Reply-To: <KM...@EX...> <DIV></DIV>>To: <DEV...@LI...> <DIV></DIV>>Subject: [Dev-C++] RE: Starting Trouble <DIV></DIV>>Date: Thu, 18 Oct 2001 17:48:27 -0700 <DIV></DIV>> <DIV></DIV>>It just hung when I invoked devcpp from the <DIV></DIV>>bash prompt. I waited for more than 10 <DIV></DIV>>mins to see what happens. <DIV></DIV>> <DIV></DIV>>I tested on RH7.1 machines with customized <DIV></DIV>>kernels (2.4.6/2.4.10). <DIV></DIV>> <DIV></DIV>>Strange thing was the CPU usage. It seemed <DIV></DIV>>to be changing. <DIV></DIV>> <DIV></DIV>>No debug messages in /var/log/messages <DIV></DIV>> <DIV></DIV>>/kmk <DIV></DIV>> <DIV></DIV>> <P>when you say "wouldn't start" what exactly do you mean? what errors <DIV></DIV>>came up on the screen? what machines have you tried it on?<BR><BR> <P></P> <DIV></DIV>> <DIV></DIV>>_______________________________________________ <DIV></DIV>>Dev-cpp-users mailing list <DIV></DIV>>Dev...@li... <DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users <DIV></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html> |
|
From: Maan M. H. <mm...@pl...> - 2001-10-19 16:56:55
|
Someone (I can not remember the name) asked on how to access RDBMS using Dev-C++. Dev-C++ works with Mingw32 or Cygwin. So the question is naturally how to access RDBMS with these compilers not with Dev-C++. To access RDBMS, you can use the Windows ODBC API, or some other library that supports ODBC. ODBC is one way of accessing RDBMS. For example, you can use WxWindows (after building the WxWindows library using Mingw or Cygwin) since WxWindows have ODBC classes. Of course, you need to set up a Data Source Name (DSN) using the ODBC manager that comes with windows. Hope this helps. Maan |
|
From: Maan M. H. <mm...@pl...> - 2001-10-19 16:11:19
|
The GCC port RSXNT comes with two very useful tools: a. makelib.exe - this converts a .dll into .a file that can be used with RSXNT, and b. lib2dll.exe - this makes a .dll from an .a file. Is there an equivalent of these two tools to use with Mingw32? Maan |
|
From: Maan M. H. <mm...@pl...> - 2001-10-19 15:49:45
|
These are some needed suggested features for Dev-C++ 1. In the Compiler Output (specially the Compiler tab part). In cases there are errors with line numbers and files/sources/headers shown in Compiler Output window -- double clicking the line number should open the file ( if it is not open already) and highlight the line number. 2. I installed Insight debugger. But I can not run it from within Dev-C++. I only get a console window which closes. Insight is working fine when I run it by itself though. 3. Is it possible to call a .rc file other than rsrc.rc? Unless I am doing something wrong, Dev-C++ does not like any name other than rsrc.rc. 4. While compiling a project, Dev-C++ always links even when I try to only compile. 5. For File.....New Project. Under Project Tab: We need a Lib (.a) section. Under GUI Toolkits: We need a wxWindows section. Thanks, Maan |
|
From: Ioannis V. <no...@ya...> - 2001-10-19 15:20:38
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Jason Hardman
> Sent: Friday, October 19, 2001 4:40 PM
> To: Dev-C++
> Subject: Re: [Dev-C++] Errorhandling
>=20
>=20
> I can say for certain that strcat() won't ever include any=20
> extra '\0' into a string. If it did it would be due to a bug=20
> in the routine. The function is passed a pointer to the=20
> beginning of two strings, so the only way it could start at=20
> the end of a string would be to look for it. The only way it=20
You can't know it. strcat() can be written even in assembly and only the
author's mind knows how it works. Simply C and C++ guarantee that you
can write these stuff with the language itself. :) When you use strcat()
don't necessarily imagine a for loop looking for the first occurence of
'\0'. This would be very slow for very large strings. A method i am now
thinking is memcpy() some large blocks and search for '\0' in each of
these blocks, but as i said a compiler makes the memory management
itself and compiler stuff may include things more close to the machine
than these we write outside of the compiler.
> can determine the end is to find the null terminator, which=20
> will be the first 0 it finds. It won't look beyond that zero,=20
> so won't see any other text or zero's that may exist. Once it=20
> has found the end of the first string it will add on the=20
> characters from the second, overwring the null terminator in=20
> the first and any other stuff that is there. It will go on=20
> till it finds the NULL on the second string and will be sure=20
> to add a NULL onto the concatenated string. Here is a short=20
> function that probably does the same as the standard one.
>=20
> MyStrCat(char *str1, const char *str2)
> {
> while(*str1) ++str1; // find end of first string
> // out now points to the null of out
> while(*str2)
> *str1++ =3D *str2++; // copy second string
> // to end of first.
> *str1 =3D 0; // null terminate
> }
That's nice for a first approach but imagine that you had a string with
5 thousand characters... As i said you can write even faster function
using C or C++ but it can be written in assembly too in something like
that:
inline void MyStrCat(char *str1, const char *str2)
{
asm("Bizarre code here");
....
}
It can be even "worse". :) Stroustrup writes in Special Edition that
they may be no header files at all and #include statements can work as
on/off switches!
E.g..
#include <cstdio> // switch that makes the cstdio library functions
accessible.
That means they are all automatically accessible and you define
accessibility using #include statements. :)
>=20
> Note that if you pass two pointers to the same string you=20
> will get an infinate loop.
>=20
> Regards Jason.
>=20
> PS: guess I've gone OTT again.... oops!
What's OTT? :)
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
|
|
From: Daniel G. <sp...@ho...> - 2001-10-19 15:09:47
|
<html><div style='background-color:'><DIV> <P>not sure about the first, but for the header try moving it to the local directory and having #include "_defs.h"<BR><BR></P></DIV> <DIV></DIV> <DIV></DIV>>From: mi...@ju... <DIV></DIV>>To: dev...@li... <DIV></DIV>>Subject: [Dev-C++] Using graphics.h <DIV></DIV>>Date: Fri, 19 Oct 2001 07:08:13 -0400 <DIV></DIV>> <DIV></DIV>>Whenever I call the header I get <DIV></DIV>> <DIV></DIV>>C:\DEV-C_~1\INCLUDE\graphics.h:24: #error BGI graphics not ANSI <DIV></DIV>>compatible <DIV></DIV>> <DIV></DIV>> and <DIV></DIV>> <DIV></DIV>> _defs.h: No such file or directory <DIV></DIV>> <DIV></DIV>>Is there anyway I can get this to work, and does anyone have _defs.h ? <DIV></DIV>>________________________________________________________________ <DIV></DIV>>GET INTERNET ACCESS FROM JUNO! <DIV></DIV>>Juno offers FREE or PREMIUM Internet access for less! <DIV></DIV>>Join Juno today! For your FREE software, visit: <DIV></DIV>>http://dl.www.juno.com/get/web/. <DIV></DIV>> <DIV></DIV>>_______________________________________________ <DIV></DIV>>Dev-cpp-users mailing list <DIV></DIV>>Dev...@li... <DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users <DIV></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html> |
|
From: Daniel G. <sp...@ho...> - 2001-10-19 15:08:33
|
<html><div style='background-color:'><DIV> <P>int holds any number from -32,332 to +32,332 (not sure about last 3 digits in each)</P> <P>and an unsigned int holds +64, 664 (again not sure about last 3)<BR><BR></P></DIV> <DIV></DIV> <DIV></DIV>>From: "Ioannis Vranos" <NO...@YA...> <DIV></DIV>>To: "Dev-C++" <DEV...@LI...> <DIV></DIV>>Subject: RE: [Dev-C++] Unsigned and signed <DIV></DIV>>Date: Fri, 19 Oct 2001 17:54:32 +0200 <DIV></DIV>> <DIV></DIV>>signed integer variables can store both positive and negative variables, <DIV></DIV>>unsigned only positive. <DIV></DIV>> <DIV></DIV>>e.g. <DIV></DIV>>int x; <DIV></DIV>>signed int x; // They are both the same <DIV></DIV>> <DIV></DIV>>unsigned int x; <DIV></DIV>> <DIV></DIV>>long y; <DIV></DIV>>signed long y; // They are both the same <DIV></DIV>> <DIV></DIV>>unsigned long y; <DIV></DIV>> <DIV></DIV>> <DIV></DIV>>In the case of int the "int" can be avoided: <DIV></DIV>> <DIV></DIV>>int x; <DIV></DIV>>signed x; // They are both the same <DIV></DIV>> <DIV></DIV>>unsigned x; <DIV></DIV>> <DIV></DIV>> <DIV></DIV>>Also normally we do not use signed but only unsigned when we need so: <DIV></DIV>> <DIV></DIV>>int x; // signed <DIV></DIV>>long y; //signed <DIV></DIV>> <DIV></DIV>>unsigned z; // unsigned int <DIV></DIV>>unsigned long y; <DIV></DIV>>unsigned char c; <DIV></DIV>> <DIV></DIV>>But a char it can be signed or unsigned. It depends from the system. <DIV></DIV>> <DIV></DIV>>E.g. char c; // it can be signed or unsigned <DIV></DIV>> <DIV></DIV>>signed char c; // signed <DIV></DIV>>unsigned char c; // unsigned <DIV></DIV>> <DIV></DIV>> <DIV></DIV>>Ioannis <DIV></DIV>> <DIV></DIV>>* Ioannis Vranos <DIV></DIV>>* Programming pages: http://www.noicys.f2s.com <DIV></DIV>>* Alternative URL: http://run.to/noicys <DIV></DIV>> <DIV></DIV>> <DIV></DIV>> <DIV></DIV>> <DIV></DIV>> > -----Original Message----- <DIV></DIV>> > From: dev...@li... <DIV></DIV>> > [mailto:dev...@li...] On Behalf <DIV></DIV>> > Of mi...@ju... <DIV></DIV>> > Sent: Friday, October 19, 2001 1:36 PM <DIV></DIV>> > To: dev...@li... <DIV></DIV>> > Subject: [Dev-C++] Unsigned and signed <DIV></DIV>> > <DIV></DIV>> > <DIV></DIV>> > What do unsigned and signed do to variables? <DIV></DIV>> > ________________________________________________________________ <DIV></DIV>> > GET INTERNET ACCESS FROM JUNO! <DIV></DIV>> > Juno offers FREE or PREMIUM Internet access for less! <DIV></DIV>> > Join Juno today! For your FREE software, visit: <DIV></DIV>> > http://dl.www.juno.com/get/web/. <DIV></DIV>> > <DIV></DIV>> > <DIV></DIV>> > _______________________________________________ <DIV></DIV>> > Dev-cpp-users mailing list <DIV></DIV>> > Dev...@li... <DIV></DIV>> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users <DIV></DIV>> > <DIV></DIV>> <DIV></DIV>> <DIV></DIV>>_______________________________________________ <DIV></DIV>>Dev-cpp-users mailing list <DIV></DIV>>Dev...@li... <DIV></DIV>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users <DIV></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html> |
|
From: Ioannis V. <no...@ya...> - 2001-10-19 14:52:53
|
signed integer variables can store both positive and negative variables, unsigned only positive.=20 e.g. int x; signed int x; // They are both the same unsigned int x; long y; signed long y; // They are both the same unsigned long y; In the case of int the "int" can be avoided: int x; signed x; // They are both the same unsigned x; Also normally we do not use signed but only unsigned when we need so: int x; // signed long y; //signed unsigned z; // unsigned int unsigned long y; unsigned char c; But a char it can be signed or unsigned. It depends from the system. E.g. char c; // it can be signed or unsigned signed char c; // signed unsigned char c; // unsigned Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of mi...@ju... > Sent: Friday, October 19, 2001 1:36 PM > To: dev...@li... > Subject: [Dev-C++] Unsigned and signed >=20 >=20 > What do unsigned and signed do to variables?=20 > ________________________________________________________________ > GET INTERNET ACCESS FROM JUNO! > Juno offers FREE or PREMIUM Internet access for less! > Join Juno today! For your FREE software, visit:=20 > http://dl.www.juno.com/get/web/. >=20 >=20 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >=20 |
|
From: Jason H. <jas...@bt...> - 2001-10-19 14:42:08
|
I can say for certain that strcat() won't ever include any extra '\0' into a
string. If it did it would be due to a bug in the routine. The function is
passed a pointer to the beginning of two strings, so the only way it could
start at the end of a string would be to look for it. The only way it can
determine the end is to find the null terminator, which will be the first 0
it finds. It won't look beyond that zero, so won't see any other text or
zero's that may exist. Once it has found the end of the first string it will
add on the characters from the second, overwring the null terminator in the
first and any other stuff that is there. It will go on till it finds the
NULL on the second string and will be sure to add a NULL onto the
concatenated string. Here is a short function that probably does the same as
the standard one.
MyStrCat(char *str1, const char *str2)
{
while(*str1) ++str1; // find end of first string
// out now points to the null of out
while(*str2)
*str1++ = *str2++; // copy second string
// to end of first.
*str1 = 0; // null terminate
}
Note that if you pass two pointers to the same string you will get an
infinate loop.
Regards Jason.
PS: guess I've gone OTT again.... oops!
----- Original Message -----
From: "Ioannis Vranos" <no...@ya...>
To: "Dev-C++" <dev...@li...>
Sent: Friday, October 19, 2001 10:25 AM
Subject: RE: [Dev-C++] Errorhandling
> Any string literal will be automatically NULL terminated
> anyway, but putting in the extra NULL wouldn't cause any harm
> as strcat would just ignore it. A C++ string would be better,
We do not know if it would ignore it, it could end up in a concatenated
string having a double '\0', and in the next call of strcat() it could
end up in something like that:
[stringonestringtwo\0stringthree...\0]
That is we do not know how a strcat() implementation works (perhaps from
the end towards the beginning) and it could replace the last '\0' only.
In any case that '\0' is not needed.
|
|
From: <mi...@ju...> - 2001-10-19 14:19:25
|
What do unsigned and signed do to variables? ________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/. |
|
From: <mi...@ju...> - 2001-10-19 14:19:24
|
Whenever I call the header I get C:\DEV-C_~1\INCLUDE\graphics.h:24: #error BGI graphics not ANSI compatible and _defs.h: No such file or directory Is there anyway I can get this to work, and does anyone have _defs.h ? ________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/. |
|
From: Daniel G. <sp...@ho...> - 2001-10-19 11:53:43
|
<html><div style='background-color:'><DIV> <P>try #include "source.cpp" the " " will tell the compiler it's in a local directory.<BR><BR></P></DIV> <DIV></DIV> <DIV></DIV>>From: "Nick Easler" <EA...@ST...> <DIV></DIV>>Reply-To: "Nick Easler" <EA...@ST...> <DIV></DIV>>To: <DEV...@LI...> <DIV></DIV>>Subject: [Dev-C++] #include <DIV></DIV>>Date: Thu, 18 Oct 2001 17:45:29 -0400 <DIV></DIV>> <DIV></DIV>>I'm learning c++ using dev-c++ and I can't seem to include source within the same project. Is there a way to setup dev-c++ so it looks for files in the current project directory when you #include them? Otherwise, I'd have to move them to the include directory, which is a real pain in the butt. <DIV></DIV>>Thanks. <DIV></DIV>>Nick Easler <DIV></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html> |
|
From: Ioannis V. <no...@ya...> - 2001-10-19 08:24:13
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of Jason Hardman > Sent: Friday, October 19, 2001 12:13 AM > To: Dev-C++ > Subject: Re: [Dev-C++] Errorhandling >=20 >=20 > I think the strcat(szDatei, " \0") was to insert a space=20 > between the comand line arguments when concatenating them.=20 The proper in this case would be: strcat(sdDatei, " "); > Any string literal will be automatically NULL terminated=20 > anyway, but putting in the extra NULL wouldn't cause any harm=20 > as strcat would just ignore it. A C++ string would be better, We do not know if it would ignore it, it could end up in a concatenated string having a double '\0', and in the next call of strcat() it could end up in something like that: [stringonestringtwo\0stringthree...\0] That is we do not know how a strcat() implementation works (perhaps from the end towards the beginning) and it could replace the last '\0' only. In any case that '\0' is not needed. =20 > but perhaps he was intentionally writing in pure C? Perhaps, but he spoke for exceptions so i assumed knowledge of C++ so i assumed C++. :) > I've been haveing a look at the C99 standard of late and some=20 > of the developments in there would make it useful to use C=20 > instead of C++. C is no longer a subset of C++, although=20 C99 is not a subset of C++ but i can;t find a reason why using C99 would be more useful than C++ (i think exactly the opposite). > maybe in future they will extend C++ to include at least some=20 > of the inovations? Of course I don't think that the compiler=20 Only very few. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys |
|
From: kmk <km...@wo...> - 2001-10-19 00:48:34
|
It just hung when I invoked devcpp from the bash prompt. I waited for more than 10 mins to see what happens. I tested on RH7.1 machines with customized kernels (2.4.6/2.4.10). Strange thing was the CPU usage. It seemed to be changing. No debug messages in /var/log/messages /kmk <P>when you say "wouldn't start" what exactly do you mean? what errors came up on the screen? what machines have you tried it on?<BR><BR></P></DIV |
|
From: <mi...@ju...> - 2001-10-18 23:00:46
|
. . .with Dev C++. I have v 4.1, so you may need to upgrade first. 1.) go to options->environment options 2.) click the editor tab 3.) on the tab indent area, check auto indent and make sure the other two boxes are unchecked Happy Coding;-) ________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/. |
|
From: Jason H. <jas...@bt...> - 2001-10-18 22:19:21
|
Hi, When you include a standard library header from the compiler you use = <...>, i.e. #include <iostream>, but when including a header that is in = the same directory as the source then you should use "...", i.e. = #include "MyHeader.h". That is probably your problem without seeing your = code You can if you want write includes with standard directory info, = i.e. #include "C:\MyProg\Myheader.h", but it's best to use relative = paths rather than specific. If you are trying to include a standard = header that isn't in the main include directory then you can go to the = options (either project or compiler; depending) and add the path to = search to the relevant field. Jason. ----- Original Message -----=20 From: Nick Easler=20 To: dev...@li...=20 Sent: Thursday, October 18, 2001 10:45 PM Subject: [Dev-C++] #include I'm learning c++ using dev-c++ and I can't seem to include source = within the same project. Is there a way to setup dev-c++ so it looks for = files in the current project directory when you #include them? = Otherwise, I'd have to move them to the include directory, which is a = real pain in the butt. Thanks. Nick Easler |
|
From: Jason H. <jas...@bt...> - 2001-10-18 22:12:55
|
I think the strcat(szDatei, " \0") was to insert a space between the comand
line arguments when concatenating them. Any string literal will be
automatically NULL terminated anyway, but putting in the extra NULL wouldn't
cause any harm as strcat would just ignore it. A C++ string would be better,
but perhaps he was intentionally writing in pure C?
I've been haveing a look at the C99 standard of late and some of the
developments in there would make it useful to use C instead of C++. C is no
longer a subset of C++, although maybe in future they will extend C++ to
include at least some of the inovations? Of course I don't think that the
compiler used in Dev-C++ supports it yet.
Jason.
----- Original Message -----
From: "Ioannis Vranos" <no...@ya...>
To: "Dev-C++" <dev...@li...>
Sent: Thursday, October 18, 2001 10:33 PM
Subject: RE: [Dev-C++] Errorhandling
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Christian Wallukat
> Sent: Thursday, October 18, 2001 2:40 PM
> To: CPP-Maillinglist (E-Mail)
> Subject: [Dev-C++] Errorhandling
>
>
> Hi list,
>
>
> I try to write a little Dos-tool.
> If I want to get the parameters and the user has no
> parameters specified I get an exception.
>
> I think the error comes if i call strlen() with an empty string...
>
> How can i handle this error, has anyone an idea ????
>
>
>
> ----------------Schnipp---------------------
> //Get commandline
> strcpy(szDatei, argv[1]); // *** access violation
// *** argv[1] doesn't exist with no commands passed!
> for (nCount = 2; argc > nCount; ++nCount)
> {
> strcat(szDatei, " ");
> strcat(szDatei, argv[nCount]);
> };
>
> //Check Commandline
> if (strlen(szDatei) <= 5)
> {
> printf("Wrong parameter !");
> };
> -------------------Schnapp------------------
>
>
> Thanx for help
>
>
> Chris
The errors may be many. For example szDatei may not have the necessary
size to hold all these strings... Except of that, strcat(szDatei, "
\0"); is a mistake. So wwe do not know if you get an exception, the most
possible is that you get memory access error.
For more bullet proof code use C++ higher level constructs like string.
E.g.
#include <iostream>
#include <string>
...
//somewhere in a function
using namespace std;
...
if(argc>1)
string szDatei=argv[1];
for (int nCount = 2; nCount<argc; ++nCount)
szDatei+= " " + argv[nCount]); // ***added a space
//Check Commandline
if (szDatei.size() <= 5)
cout<<"Wrong parameter !";
This is the equivallent higher level C++ code with your mistakes
corrected (the first if statement, and int nCount in the for loop).
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Nick E. <ea...@st...> - 2001-10-18 21:47:06
|
I'm learning c++ using dev-c++ and I can't seem to include source within = the same project. Is there a way to setup dev-c++ so it looks for files = in the current project directory when you #include them? Otherwise, I'd = have to move them to the include directory, which is a real pain in the = butt. Thanks. Nick Easler |
|
From: Ioannis V. <no...@ya...> - 2001-10-18 20:32:14
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Christian Wallukat
> Sent: Thursday, October 18, 2001 2:40 PM
> To: CPP-Maillinglist (E-Mail)
> Subject: [Dev-C++] Errorhandling
>=20
>=20
> Hi list,
>=20
>=20
> I try to write a little Dos-tool.
> If I want to get the parameters and the user has no=20
> parameters specified I get an exception.
>=20
> I think the error comes if i call strlen() with an empty string...
>=20
> How can i handle this error, has anyone an idea ????
>=20
>=20
>=20
> ----------------Schnipp---------------------
> //Get commandline
> strcpy(szDatei, argv[1]);
> for (nCount =3D 2; argc > nCount; ++nCount)
> {
> strcat(szDatei, " \0");
> strcat(szDatei, argv[nCount]);
> };
>=20
> //Check Commandline
> if (strlen(szDatei) <=3D 5)=20
> {
> printf("Wrong parameter !");
> };
> -------------------Schnapp------------------
>=20
>=20
> Thanx for help
>=20
>=20
> Chris
The errors may be many. For example szDatei may not have the necessary
size to hold all these strings... Except of that, strcat(szDatei, "
\0"); is a mistake. So wwe do not know if you get an exception, the most
possible is that you get memory access error.
For more bullet proof code use C++ higher level constructs like string.
E.g.
#include <iostream>
#include <string>
...
//somewhere in a function
using namespace std;
...
if(argc>1)
string szDatei=3Dargv[1];
for (int nCount =3D 2; nCount<argc; ++nCount)
szDatei+=3D argv[nCount]);
//Check Commandline
if (szDatei.size() <=3D 5)=20
cout<<"Wrong parameter !";
This is the equivallent higher level C++ code with your mistakes
corrected (the first if statement, and int nCount in the for loop).
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
|
|
From: Jason H. <jas...@bt...> - 2001-10-18 14:04:36
|
You are trying to access an argv member that doesn't exist, in the strcpy()
function. The array starts at zero so with an empty command line only
argv[0] will be valid and it will contain the name of the executable.
Jason.
----- Original Message -----
From: "Christian Wallukat" <Chr...@vo...>
To: "CPP-Maillinglist (E-Mail)" <dev...@li...>
Sent: Thursday, October 18, 2001 1:40 PM
Subject: [Dev-C++] Errorhandling
> Hi list,
>
>
> I try to write a little Dos-tool.
> If I want to get the parameters and the user has no parameters specified I
> get an exception.
>
> I think the error comes if i call strlen() with an empty string...
>
> How can i handle this error, has anyone an idea ????
>
>
>
> ----------------Schnipp---------------------
> //Get commandline
> strcpy(szDatei, argv[1]); // ** try argv[0]**
> for (nCount = 2; argc > nCount; ++nCount)
> {
> strcat(szDatei, " \0");
> strcat(szDatei, argv[nCount]);
> };
>
> //Check Commandline
> if (strlen(szDatei) <= 5)
> {
> printf("Wrong parameter !");
> };
> -------------------Schnapp------------------
>
>
> Thanx for help
>
>
> Chris
>
> Diese Mail wurde auf Viren überprüft.
> This mail was checked for virusses.
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Christian W. <Chr...@vo...> - 2001-10-18 12:38:34
|
Hi list,
I try to write a little Dos-tool.
If I want to get the parameters and the user has no parameters specified I
get an exception.
I think the error comes if i call strlen() with an empty string...
How can i handle this error, has anyone an idea ????
----------------Schnipp---------------------
//Get commandline
strcpy(szDatei, argv[1]);
for (nCount = 2; argc > nCount; ++nCount)
{
strcat(szDatei, " \0");
strcat(szDatei, argv[nCount]);
};
//Check Commandline
if (strlen(szDatei) <= 5)
{
printf("Wrong parameter !");
};
-------------------Schnapp------------------
Thanx for help
Chris
Diese Mail wurde auf Viren überprüft.
This mail was checked for virusses.
|
|
From: Luigi S. <gi...@li...> - 2001-10-18 04:06:41
|
Thank you for your answers -- gisan gi...@li... |