|
From: Brian C. <bri...@ho...> - 2001-09-06 07:33:43
|
Hi, I am having problems when I try to execute my programs.
To start off, I am writing basic Console Applications. This is a basic
application that I am trying to get to work.
***********************************************
#include <stdio.h>
#include <iostream.h>
int main(int argc, char *argv[])
{
int Age;
cout << "What is your age?\n";
cin >> Age;
cout << "Your age is " << Age << " .\n";
return 0;
}
Well, as you can see, I ask the user to imput their age. Then as soon
as they do and press enter, you can see it display the cout string that
tells them their age, but it only displays it for a second and then the
window closes.
My question was, is there a tag that I can add to keep it from closing
the window immediatly? I am not sure if it just a bug, or I just have a
missing string. But the reason I am confused is because I am taking a
programming course at college, and we use Microsoft Visual C++. The only
difference that I see is instead of the <stdio.h> tag at the top of the
program, we use <stdafx.h>. Could this have anything to do with it, or is
there just another string that this program uses that makes it finish
answering the question and not just immediatly terminate the program.
Any feedback you could give me would be greatly appreciative.
Thank You,
Brian Crabtree
Reidsville NC
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|
|
From: <jd...@da...> - 2002-06-21 22:04:12
|
C++ Exceptions are not catched!!!!!!!!!!!!!!!
Why?
I had build a Dll who throws some exception but the program who calls dll
methods don't catch exceptions and closes abnormally.
Then I tried this simple exe: don't works at all.
Here the simple exe's code.
There's something wrong?
Please help me. (I use Dev 4.9.3.0)
#include <sys/types.h>
#include <iostream.h>
#include <stdlib.h>
class Vector
{
private:
size_t si;
int *value;
public:
class BadIndex {};
class BadSize {};
class BadAllocation {};
Vector (size_t);
int& operator[](size_t);
};
Vector::Vector (size_t s)
{
if (s <= 0) throw BadSize();
si = s;
value = new int[si];
if (value == 0) throw BadAllocation();
}
int& Vector::operator[] (size_t i)
{
if ((i < 0) || (i >= si)) throw BadIndex();
return value[i];
}
int main (int, char **)
{
Vector *v;
try
{
int si, index;
cout << "Give the size of the array: ";
cin >> si;
v = new Vector (si);
cout << "Give an index in the array: ";
cin >> index;
cout << "Give its value: ";
cin >> (*v)[index];
}
catch (Vector::BadSize)
{
cerr << "The size of an array must be greater than 0.\n";
exit(1);
}
catch (Vector::BadAllocation)
{
cerr << "Memory allocation error.\n";
exit(2);
}
catch (Vector::BadIndex)
{
cerr << "Index out of range.\n";
exit(3);
}
//...
system("pause");
exit(0);
}
)
(
[_] Johnny
|
|
From: Ioannis V. <no...@ho...> - 2002-06-22 10:22:51
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Johnny Dess=B5
> Sent: Saturday, June 22, 2002 1:00 AM
> To: Dev-Cpp
> Subject: [Dev-C++] Help
>=20
>=20
> C++ Exceptions are not catched!!!!!!!!!!!!!!!
>=20
> Why?
>=20
> I had build a Dll who throws some exception but the program=20
> who calls dll
> methods don't catch exceptions and closes abnormally.
> Then I tried this simple exe: don't works at all.
> Here the simple exe's code.
> There's something wrong?
> Please help me. (I use Dev 4.9.3.0)
>=20
>=20
> #include <sys/types.h>
> #include <iostream.h>
> #include <stdlib.h>
> class Vector
> {
> private:
> size_t si;
> int *value;
> public:
> class BadIndex {};
> class BadSize {};
> class BadAllocation {};
> Vector (size_t);
> int& operator[](size_t);
> };
> Vector::Vector (size_t s)
> {
> if (s <=3D 0) throw BadSize();
> si =3D s;
> value =3D new int[si];
> if (value =3D=3D 0) throw BadAllocation();
> }
> int& Vector::operator[] (size_t i)
> {
> if ((i < 0) || (i >=3D si)) throw BadIndex();
> return value[i];
> }
> int main (int, char **)
> {
> Vector *v;
> try
> {
> int si, index;
> cout << "Give the size of the array: ";
> cin >> si;
> v =3D new Vector (si);
> cout << "Give an index in the array: ";
> cin >> index;
> cout << "Give its value: ";
> cin >> (*v)[index];
> }
> catch (Vector::BadSize)
> {
> cerr << "The size of an array must be greater than 0.\n";
> exit(1);
> }
> catch (Vector::BadAllocation)
> {
> cerr << "Memory allocation error.\n";
> exit(2);
> }
> catch (Vector::BadIndex)
> {
> cerr << "Index out of range.\n";
> exit(3);
> }
> //...
> system("pause");
> exit(0);
> }
>=20
> )
> (
> Executing: C:\Program Files\ConTEXT\ConExec.exe "g++" "temp.cpp" -o
temp -ansi -pedantic-errors -Wall -fexpensive-optimizations -O3
-ffloat-store -mcpu=3Dpentiumpro
In file included from c:/mingw/include/g++-v3/backward/iostream.h:31,
from temp.cpp:2:
c:/mingw/include/g++-v3/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section
17.4.1.2 of the C++ standard. Examples include substituting the <X>
header for the <X.h> header for C++ includes, or <sstream> instead of
the deprecated header <strstream.h>. To disable this warning use
-Wno-deprecated.
> Execution finished.
C:\c>temp
Give the size of the array: 0
The size of an array must be greater than 0.
I think it works ok to me. But you use the old style standard C++
headers which is deprecated (are not developed anymore in the latest
versions of compilers, and are kept for backward compatibility only).
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|
|
From: Nancy A. <nai...@ho...> - 2003-08-22 03:25:39
Attachments:
cpp_home.txt
|
/***************************************************************************
CALCULO DEWT
Sistema ternario: acetona(1)/metano(2)/agua(3)
****************************************************************************
Data: 16/08/2003
Calculo DEWT com o metodo de Wilson para os coeficientes de atividade em um
sistema ternario usando o metodo de Newton-Raphson para a solucao aproximada
do sistema de equacoes estabelecido.
ENTRADAS:
Numero de equacoes, n, e de desconhecidos, z=(z1,...,zn)t, tolerancia TOL;
numero
maximo de iteracoes Max; equacoes para F(z)=0 na funcao F() e para J(z) em
jaco-
biana().
Dados do sistema desde o arquivo cpp-dados.txt: pressao (P); fracao molar
dos com-
ponentes na entrada do sistema, (y(0,..,n-1)); volume molar de cada
componente da
mistura, v(0,..,n); constantes de Antoine, A(0,..,n), B(0,..,n) e C(0,..n),
para o
calculo das presoes de saturacao de cada componente; constantes da equacao
de Wil-
son, a(ij), para cada par de componentes.
SAIDA: solucao aproximada z = (z1,...,zn)t ou mensagen de que o numero de
iteracoes
foi excedido.
******************************************************************************/
#include<fstream.h>
#include <iostream.h>
#include <math.h>
#include <stdlib.h>
/*** Prototipo das funcoes usadas ***/
/************************************/
double pressat(double , double *, double* , double *, double *);
double atividade(int ,double **, double **, double *);
double wilson(double *, double **, double &, double **) ;
void msg1();
double valor(int , int , double *, double **, double *, double *, double *);
double derGx(int, int, double **, double *, double **, double**,double **);
double derF (int , int , double *, double **, double **, double *, double
**);
double Jacobiana(double **, double *, double **, int, double**);
double Inversa(double** , int, double** );
/* Declara variaveis globais */
/****************************/
const double R=1.987, /* constante dos gases*/
ff=1e-4;
int n, c; /*número de equacoes e numero de
especies quimicas*/
/***************************************************************************/
int main () { //INICIO DO MAIN
/***************************************************************************/
/**** Declara variaveis locais ****/
int i,j,k,l,m,kk,jj; /* índices */
int Max; /* número máximo de iterações */
double TOL, /* tolerancia */
P, /* Presao do sistema*/
soma, /* auxiliar de calculo;*/
erro; /* erro de aproximacao */
double *y, /* fracao molar de cada especie no
vapor*/
*v, /* volume molar de cada especie */
*A,*B,*C, /* constantes de Antoine*/
*Gamma, /* coeficiente de atividade*/
*Psat, /* presao de saturacao*/
*F, /* vetor de funcoes*/
**Gder, /* termo a direita para a derivada
numerica*/
**Fder, /* termo a direita paara a derivada
numerica*/
**z, /* vetor de incognitas*/
**vji, /* radio vj/vi na correlacao de Wilson*/
**a, /* constante de interacao binaria de
Wilson*/
**LAMBDA, /* termo de interacao molecular da
equacao de Wilson*/
**J, /* matriz jacobiana */
**JINV; /* jacobiana inversa */
ifstream OpenFile; OpenFile.open("cpp_home.txt");
ofstream SaveFile; SaveFile.open("cpp_DEWT.txt");
SaveFile<<endl<<"Sistema ternario: acetona(1)/metano(2)/agua(3)"<<endl;
SaveFile<<endl<<" Calcula T, x1, x2 e x3 no ponto de orvalho"<<endl;
/***************************/
/* ENTRADAS */
/***************************/
cout<<"Entrar numero maximo de iteracoes, Max: ";
cin>>Max;
cout<<endl<<"Entrar a Tolerancia. TOL (1.0e-5)?: ";
cin>>TOL;
cout<<"Lendo numero de equacoes, n: "<<endl;
OpenFile>>n; cout<<n<<endl;
if (n <= 0)
cout<<"ERROR - n tem que ser maior que zero.\n"<<endl;
SaveFile<<"O sistema tem "<<n<<" equacoes e "<<n<<" desconhecidos."<<endl;
/******** Alocacao dinamica da memoria *******/
c=n-1;
y = new double [c]; if (y==NULL)msg1();
v = new double [c]; if (v==NULL)msg1();
A = new double [c]; if (A==NULL)msg1();
B = new double [c]; if (B==NULL)msg1();
C = new double [c]; if (C==NULL)msg1();
Psat = new double [c]; if (Psat==NULL)msg1();
Gamma = new double [c]; if (Gamma==NULL)msg1();
F = new double [n]; if (F==NULL)msg1();
a = new double *[c]; if (a==NULL)msg1(); for (i=0; i<c; i++){
a[i] = new double [c]; if(a[i]==NULL)msg1();}
z = new double *[n]; if (z==NULL)msg1(); for (i=0; i<n; i++){
z[i] = new double [Max]; if(z[i]==NULL)msg1();}
Gder = new double *[c]; if(Gder==NULL)msg1(); for (i=0; i<c; i++){
Gder[i] = new double [n]; if(Gder[i]==NULL)msg1();}
LAMBDA = new double *[c]; if (LAMBDA==NULL)msg1(); for ( i=0; i<c;
i++){
LAMBDA[i] = new double [c]; if (LAMBDA[i]==NULL)msg1();}
Fder = new double *[n]; if (Fder==NULL)msg1(); for (int i=0; i<n;
i++){
Fder[i] = new double [n]; if(Fder[i]==NULL)msg1();}
J = new double *[n]; if (J==NULL)msg1(); for (int i=0; i<n;
i++){
J[i] = new double [n]; if(J[i]==NULL)msg1();}
JINV = new double *[n]; if (JINV==NULL)msg1(); for (int i=0; i<n;
i++){
JINV[i] = new double [n]; if(JINV[i]==NULL)msg1();}
OpenFile >> P;
for (i=0; i<c-1; i++)OpenFile >>y[i];
for (i=0; i<c; i++)OpenFile >>v[i];
for (i=0; i<c; i++)OpenFile >>A[i];
for (i=0; i<c; i++)OpenFile >>B[i];
for (i=0; i<c; i++)OpenFile >>C[i];
OpenFile >> a[0][1]>> a[0][2];
OpenFile >> a[1][0]>> a[1][2];
OpenFile >> a[2][0]>> a[2][1];
//SaveFile<<"pressao do sistema: "<<P<<endl;
//SaveFile<<"fracao molar na fase vapor: "<<endl;
soma=0;
for(i=0; i<c-1; i++)soma+=y[i];
y[c-1]=1-soma;
for(i=0; i<c; i++)
//SaveFile<<" y"<<i<<"="<<y[i]<<endl;
//SaveFile<<"volume molar das especies:"<<endl;
//for (i=0; i<c; i++) SaveFile<<" v"<<i<<"="<<v[i]<<endl;
//SaveFile<<"coeficientes de Antoine:"<<endl;
for (i=0; i<c; i++)
//SaveFile<<" A"<<i<<"="<<A[i]<<", B"<<i<<"="<<B[i]<<",
C"<<i<<"="<<C[i]<<endl;
//SaveFile<<"parametros de ajuste de Wilson"<<endl;
//SaveFile<<"a12="<<a[0][1]<<" a13="<<a[0][2]<<endl;
//SaveFile<<"a21="<<a[1][0]<<" a23="<<a[1][2]<<endl;
//SaveFile<<"a31="<<a[2][0]<<" a32="<<a[2][1]<<endl;
for(i=0; i<c; i++)a[i][i]=0;
k = 0;
cout<<"Entrar as aproximacoes iniciais:"<<endl; /*
z[i][0]*/
for (i=0;i<c;i++) {//1
cout<<"x"<<i<<"0: ";
cin>>z[i][0];
}//1
cout<<"T0:";
cin>>z[c][0];
for (i=0; i<n; i++) {//2
SaveFile<<"z["<<i<<"]="<<z[i][0]<<endl; /*Imprime as aproximacoes
iniciais*/
cout<<endl;
}//2
for(i=0; i<c; i++)a[i][i]=0;
/*******************************************************/
/* PROCEDIMENTO ITERATIVO */
/******************************************************/
while ( k<Max) { //Inicio do while
SaveFile<<"k"<<k+1<<endl;
/* Calculo dos coeficientes de atividade com a correlacao de Wilson */
wilson(v,a,z[c][k],LAMBDA); /* obtem os parametros adjustaveis de
Wilson*/
/*for (i=0; i<c; i++){//3
for (j=0; j<c; j++)
SaveFile<<"L["<<i<<j<<"]="<<LAMBDA[i][j]<<endl;
}//3 */
// SaveFile<<"Coeficientes de Atividade calculadas"<<endl;
atividade(k,z,LAMBDA,Gamma); /* Obtem os coeficiente de atividade*/
//for(i=0; i<c; i++)SaveFile<<"Gamma["<<i<<"]="<<Gamma[i]<<endl;
//SaveFile<<"Presões de saturação calculadas"<<endl;
pressat(z[c][k],A,B,C,Psat); /* Calcula as presoes de saturacao */
//for (i=0; i<c; i++) SaveFile<<" Psat"<<i<<"="<<Psat[i]<<endl;
//SaveFile<<"Vetor F[z]:"<<endl ;
valor(0, k, y, z, Gamma, Psat, F);
valor(1,k,y,z,Gamma, Psat,F);
valor (2,k,y,z, Gamma, Psat, F);
valor(3,k,y,z,Gamma, Psat,F); /* Calcula o vetor F[i] */
// SaveFile<<"F"<<i<<"="<<F[i]<<endl;
/*************************************************************/
/* Calculo dos elementos da Jacobiana */
/*************************************************************/
for(i=0; i<c; i++) /* Calculo valores no ponto
(1+ff)*z */
derGx(i, k, z, v, a, LAMBDA, Gder);
for(i=0; i<c; i++)
derF(i, k, y, z, Gder, Psat, Fder);
derF(c, k, y, z, Gder, Psat, Fder);
Jacobiana(Fder, F, z, k, J); /* Calcula dFz/dz */
/* for(i=0; i<n; i++)
for(j=0; j<n; j++)
SaveFile<<"J"<<i<<j<<"="<<J[i][j]<<endl; */
/*************************************************************/
/* Solucao do sistema linear nxn J(X)*DeltaZ = -F(X) */
/*************************************************************/
Inversa(J, n, JINV) ; /* Inverte a Jacobiana */
/* for(i=0; i<n; i++)
for(j=0; j<n; j++)
SaveFile<<"JINV"<<i<<j<<"="<<JINV[i][j]<<endl;*/
for (i=0; i<n; i++){//5
soma=0;
for(j=0; j<n; j++){soma+=-JINV[i][j]*F[j];
// SaveFile<<soma<<endl;
}
z[i][k+1]=z[i][k]+soma; /*Novas estimativas*/
SaveFile<<"z["<<i<<"]["<<k+1<<"]="<<z[i][k+1]<<endl; /*
imprime a solucao na
k+1
iteracao no arquivo de saida */
} //5
/***********
* SAIDAS *
***********/
erro=0;
for (i=0; i<n; i++){//6
erro+=fabs((z[i][k+1]-z[i][k])/z[i][k]);
// SaveFile<<erro<<endl;
}//6
//SaveFile<<"erro"<<erro<<endl;
if (k+1>=1){//7a
if (erro<= TOL) {//7 /* Checa precisao da nova estimativa */
/* Libera memoria */
delete []y; delete []v; delete []A; delete []B; delete []C; delete
[]Gamma;
for (int i=0; i<c; i++) delete[] a[i]; delete [] a ;
for (int i=0; i<n; i++) delete[] Gder[i]; delete [] Gder ;
for (int i=0; i<n; i++) delete[] z[i]; delete []z;
for (int i=0; i<c; i++) delete []LAMBDA[i]; delete []LAMBDA;
for (int i=0; i<c; i++) delete[] Fder[i]; delete [] Fder ;
for (int i=0; i<n; i++) delete []J[i]; delete []J;
for (int i=0; i<n; i++) delete []JINV[i]; delete []JINV;
exit (1); /* Procedimento completado com
sucesso */
}//7
}//7a
k++; /* k = k + 1 */
}
SaveFile<<endl<<" Numero Maximo de iteracoes foi excedido."<<endl;
/* Libera a memoria */
delete []y; delete []v; delete []A; delete []B; delete []C; delete
[]Gamma;
delete []Psat; delete []F;
for (int i=0; i<c; i++) delete[] a[i]; delete [] a ;
for (int i=0; i<n; i++) delete[] Gder[i]; delete [] Gder ;
for (int i=0; i<n; i++) delete[] z[i]; delete []z;
for (int i=0; i<c; i++) delete []LAMBDA[i]; delete []LAMBDA;
for (int i=0; i<c; i++) delete[] Fder[i]; delete [] Fder ;
for (int i=0; i<n; i++) delete []J[i]; delete []J;
for (int i=0; i<n; i++) delete []JINV[i]; delete []JINV;
system("PAUSE");
return 0;
} /* Parar */
/*******************/
void msg1()
/******************/
{
cout<<"Nao consegui alocar memoria"<<endl;
exit(1);
}
/***********************************************************************/
double wilson(double *v, double **a, double &z, double **LAMBDA)
/***********************************************************************/
{ //INICIA
int i, j, c=3;
double **vji;
vji=new double *[c];
for(i=0; i<c; i++)vji[i]=new double[c];
for (i=0; i<c; i++){//1
for (j=0; j<c; j++){//2
vji[i][j]= v[j]/v[i];
a[i][j]=a[i][j]/1.987;
}//2
} //1
for (i=0; i<c; i++){//3
for (j=0; j<c; j++){//4
if(j==i)LAMBDA[i][j]=1.;
else
LAMBDA[i][j]=vji[i][j]*exp(-a[i][j]/z);
}//4
}//3
}//FINAL
/*******************************************************************/
double atividade(int k, double **z, double **LMBDA, double *Gamma)
/*******************************************************************/
{//INICIO
int i, kk,j, c=3;
double somakkjj, somak, somaj;
for (i=0; i<c; i++){/*1*/
somak=0;
for (kk=0; kk<c; kk++){ /*2*/
somakkjj=0;
for (j=0; j<c; j++)somakkjj+=z[j][k]*LMBDA[kk][j];
somak+= z[kk][k]*LMBDA[kk][i]/somakkjj;
}/*2*/
somaj=0;
for (j=0; j<c; j++) somaj+=z[j][k]*LMBDA[i][j];
Gamma[i]=exp(1-log(somaj)-somak);
}/*1*/
}//FINAL
/********************************************************************************/
double pressat(double z, double *A, double *B, double *C,double *Psat )
/********************************************************************************/
{ //INICIO
int i, n=3;
for(i=0; i<n; i++){//1
Psat[i]=exp(A[i]-B[i]/(z+C[i]));
}//1
}//FINAL
/***********************************************************************************/
double valor(int f, int k, double *y, double **z, double *G, double *Ps,
double *F)
/***********************************************************************************/
{//INICIO
if(f==0) F[0]=y[0]-z[0][k]*G[0]*(Ps[0]/101.303);
if(f==1) F[1]=y[1]-z[1][k]*G[1]*(Ps[1]/101.303);
if(f==2) F[2]=y[2]-z[2][k]*G[2]*(Ps[2]/101.303);
if(f==c) F[c]=z[0][k]+z[1][k]+z[2][k]-1;
}//FINAL
/***********************************************************************************/
double derGx(int f,int k,double **z,double *v,double **a,double **L, double
**Gder)
/***********************************************************************************/
{ //INICIO
int i,j, c=3;
double *Gd, **zp;
Gd = new double[n];
zp=new double*[n];
for(i=0; i<n; i++)zp[i]=new double[k];
for(i=0; i<n; i++)
zp[i][k]=z[i][k];
if(f==0){//0
zp[0][k]=(1+ff)*zp[0][k]; /* cout<<"gder"<<zp[0][k]<<endl;
cout<<"gder"<<zp[1][k]<<endl; cout<<"gder"<<zp[2][k]<<endl;
cout<<"gder"<<zp[3][k]<<endl; */
atividade(k, zp, L, Gd);
for(i=0; i<c; i++)Gder[i][0]=Gd[i];
}//0
//cout<<endl;
if(f==1){//1 // cout<<f<<endl;
zp[1][k]= (1+ff)*zp[1][k]; /* cout<<"gder"<<zp[0][k]<<endl;
cout<<"gder"<<zp[1][k]<<endl; cout<<"gder"<<zp[2][k]<<endl;
cout<<"gder"<<zp[3][k]<<endl;*/
atividade(k, z, L, Gd);
for(i=0; i<c; i++)Gder[i][1]=Gd[i];
}//1
//cout<<endl;
if(f==2){//2 // cout<<f<<endl;
zp[2][k]= (1+ ff)*zp[2][k]; /* cout<<"gder"<<zp[0][k]<<endl;
cout<<"gder"<<zp[1][k]<<endl; cout<<"gder"<<zp[2][k]<<endl;
cout<<"gder"<<zp[3][k]<<endl;*/
atividade(k, z, L, Gd);
for(i=0; i<c; i++)Gder[i][2]=Gd[i];
}//2
// cout<<endl;
if(f==3){//3 //cout<<f<<endl;
zp[3][k]=(1+ff)*zp[3][k]; /*cout<<"gder"<<zp[0][k]<<endl;
cout<<"gder"<<zp[1][k]<<endl; cout<<"gder"<<zp[2][k]<<endl;
cout<<"gder"<<zp[3][k]<<endl;*/
for(i=0; i<c; i++){//a
for(j=0; j<c;j++){//b
L[i][j]=exp((v[j]/v[i])*exp(-a[i][j]/z[3][k]));
}//b
}//a
atividade(k, z, L, Gd);
for(i=0; i<c; i++)Gder[i][3]=Gd[i];
}//3 /*cout<<"gfin"<<z[0][k]<<endl;
/*cout<<"gfin"<<z[1][k]<<endl;
cout<<"gfin"<<z[2][k]<<endl;
cout<<"gfin"<<z[3][k]<<endl;*/
delete[]Gd;
}//FINAL
/**********************************************************************************************/
double derF(int f, int k, double *y, double **z, double **Gder, double *Ps,
double **Fder)
/**********************************************************************************************/
{//INICIO
int i,j, c=3, n=4;
double *zp;
zp=new double[n];
for (i=0; i<c; i++){//1
zp[i]=(1+ff)*z[i][k];
for (j=0; j<n; j++){ //1a
if(i==j)Fder[i][j]=y[i]-Gder[i][i]*(Ps[i]/101.33)*zp[i];
else
Fder[i][j]=y[i]-Gder[i][j]*(Ps[i]/101.33)*z[i][k];
}//1a
}//1
} //FINAL* */
/***************************************************************************/
double Jacobiana(double **Fder, double *F, double **z, int k, double **J)
/***************************************************************************/
{//INICIO
int i,j, n=4;
double a, d;
for (i=0; i<c; i++){//1
a=z[i][k];
d=(1+ff)*z[i][k]; /*cout<<"a="<<a<<"
d="<<d<<endl;*/
cout<<endl;
for (j=0; j<n; j++){//1a
J[i][j]=(Fder[i][j]-F[i])/(d-a);
/*cout<<endl<<"(Fder"<<i<<j<<"="<<Fder[i][j]<<"-F"<<i<<"="<<F[i]<<
"/(d="<<d<<"-a="<<a<<")=
J"<<i<<j<<"="<<J[i][j];endl; */
}//1a
cout<<endl;
}//1
for(i=0; i<n; i++)J[c][i]=1;
J[c][c]=0; // for (i=0; i<n; i++){//1
for (j=0; j<n; j++) cout<<"J"<<i<<j<<"="<<J[i][j]<<endl;}//1
}//FINAL
/********************************************************************/
double Inversa(double **J, int n, double **JINV)
/*******************************************************************/
{//INICIO
double Temp, **One;
int i,j,m,l;
One= new double *[n];
for(i=0; i<n; i++)One[i]=new double[n];
/*** Criando a matriz identidade ***/
for (i=0; i<n; i++){//1
for (j=0; j<n; j++){//2
if(i==j)One[i][j]=1;
else One[i][j]=0;
// cout<<"one="<<One[i][j]<<endl;
}//2
}//1
/*** Inversao da Jacobiana ***/
for (l=0; l<n; l++){//7
cout<<l<<endl;
Temp=J[l][l];
for (j=0; j<n; j++) {//8
J[l][j]=J[l][j]/Temp;
One[l][j]=One[l][j]/Temp;
}//8
for (m=l+1; m<n; m++) {//9
Temp=J[m][l];
for (j=0; j<n; j++){ //10
J[m][j]=-1*Temp*J[l][j]+J[m][j];
One[m][j]=-1*Temp*One[l][j]+One[m][j];
} //10
} //9
} //7
for (l=c; l>=0; l--) { //11
for (m=l-1; m>=0; m--){ //12
Temp=J[m][l];
for (j=0; j<n; j++) {//13
J[m][j]=-1*Temp*J[l][j]+J[m][j];
cout<<endl;
One[m][j]=-1*Temp*One[l][j]+One[m][j];
} //13
} //12
} //11
for (i=0; i<n; i++){
for (j=0; j<n; j++){
JINV[i][j]=One[i][j];
}
}
}//FINAL
|
|
From: Michael D. S. <for...@hi...> - 2003-08-22 07:22:50
|
First I click on nothing in the email for obvious reasons :) But here's a good guess without looking. Usually, you have a loop going that's addressing an array and at loop 30=20 the address is out of bounds of the array. If array A has 30 elements, the last element is A[29] -- A[0] is the first.= =20 If you try to address A[30] that gets into memory that's reserved for other= =20 things. This of course usually happens in a "for" or "while" loop with=20 A[index] where "index =3D" gets to be 30 -- or perhaps even more. Put a cout statement in your loop and print out the control variable. See=20 what it is in the last loop that works. Then you can figure out what it was= =20 on the fatal loop, maybe even see it if the cout statement executes before= =20 the fatal error occurs. And, maybe not. Errors can cause other errors that have nothing to do with= =20 the first error. Then the trick is to find the one that started the chain. ms At 10:25 PM 8/21/03, you wrote: > > >hello,<?xml:namespace prefix =3D o ns =3D=20 >"urn:schemas-microsoft-com:office:office" /> > > i have a problem with execution of program in DEV-C++ > >This program stop in the thirth iteration. Here appear a message of error= =20 >that talks problems read the address of memory . > >why ? > >could you help me ?? > > Hope be helped, >=20 >Nancy Alvarez > > >---------- >Charla con tus amigos en l=EDnea mediante MSN Messenger:=20 ><http://g.msn.com/8HMDES/2728??PS=3D>Haz clic aqu=ED |
|
From: Walter N. Jr. <wa...@it...> - 2004-04-09 12:27:59
|
Dear devcpp users, I'm starting using a Devc++ compiler. How can I get an User manual ?? Thanks, Walter Nabuco Jr. Brazil |
|
From: Roger A. F. <ra...@ha...> - 2004-07-21 09:19:47
|
Aloha from Honolulu,
I just subscribed to the mailing list. I hope this is the right place to
ask questions.
I don't know which version came on the CD because as I proceeded with
the installation I was asked if I wanted the latest version and of
course I clicked "Yes". The story so far: I purchased "Sams Teach
Yourself C++ in 24 hours" by Jesse Liberty. The book included a CDROM
with all the source code for the exercises and the Dev-C++ IDE (as well
as a command line compiler and a debugger I haven't gotten to yet). The
"About" under the Help menu lists my current version as "Version 4 Build
on: 9/21/00 11:22:34PM". Clicking on "Check for Updated Version" returns
a notice that such exists. But as your web page warns of earlier
programs not compiling under this new version, I think I'll wait.
My immediate need is covered in the FAQ under the Help menu. The
question #2. "When executing my dos program, it closes automatically.
How I can change this ?" gives a little snippet of code:
#include <stdlib.h>
int main()
{
system("PAUSE");
return 0;
}
When I tried to include this in my program I got the following error
mesage in the compiler window:
"c:\dev-c_~1\examples\hello\pause.cpp:6: parse error before character 0223"
And the color of "PAUSE" (including the quotes) is red in the help file,
but shows up black in my source.
I tried unchecking the "Create for win32" in Compiler Options and also
tried working within a project and unchecking the "Do not create a
console" in Project Options. Neither had any effect--in fact they were
not checked to begin with. In earlier lessons I was able to use this
little bit:
#include <iostream>
int main()
{
char quit;
while (quit != 'q')
std::cout<<"Press q to quit " << std::endl;
std::cin>>quit;
return 0;
}
to keep the DOS window open. But this isn't possible in some cases (as I
discovered).
I hope you can help me with this problem and let me know via email. Or
tell me where to look if this gets posted somewhere.
Mahalo (Thank You),
Roger Furer
ra...@ha...
|
|
From: Scott S. <age...@co...> - 2004-07-21 15:44:16
|
Roger Allan Furer wrote: > Aloha from Honolulu, > I just subscribed to the mailing list. I hope this is the right place > to ask questions. > I don't know which version came on the CD because as I proceeded with > the installation I was asked if I wanted the latest version and of > course I clicked "Yes". The story so far: I purchased "Sams Teach > Yourself C++ in 24 hours" by Jesse Liberty. The book included a CDROM > with all the source code for the exercises and the Dev-C++ IDE (as > well as a command line compiler and a debugger I haven't gotten to > yet). The "About" under the Help menu lists my current version as > "Version 4 Build on: 9/21/00 11:22:34PM". Clicking on "Check for > Updated Version" returns a notice that such exists. But as your web > page warns of earlier programs not compiling under this new version, I > think I'll wait. I have no problem with compiles in the newer version. Consider downloading 4.9.8.0 from the website, www.bloodshed.net. Then, upgrade to 4.9.8.10. Version 4 isn't supported anymore. In fact, the compiler Dev-C++ uses, MinGW, is more reliable than Microsoft's compiler for me! > My immediate need is covered in the FAQ under the Help menu. The > question #2. "When executing my dos program, it closes automatically. > How I can change this ?" gives a little snippet of code: > > #include <stdlib.h> > int main() > { > system("PAUSE"); > return 0; > } A better solution is to include <iostream> and use cin.get(). It is more portable, and would look like this: #include <iostream> using namespace std; int main() { cin.get(); return 0; } > > When I tried to include this in my program I got the following error > mesage in the compiler window: > "c:\dev-c_~1\examples\hello\pause.cpp:6: parse error before character > 0223" > > And the color of "PAUSE" (including the quotes) is red in the help > file, but shows up black in my source. You can change the colors used by going to Tools->Editor Options->Syntax > > I tried unchecking the "Create for win32" in Compiler Options and also > tried working within a project and unchecking the "Do not create a > console" in Project Options. Neither had any effect--in fact they were > not checked to begin with. In earlier lessons I was able to use this > little bit: > > #include <iostream> > int main() > { > char quit; > while (quit != 'q') > std::cout<<"Press q to quit " << std::endl; > std::cin>>quit; > return 0; > } > to keep the DOS window open. But this isn't possible in some cases (as > I discovered). > > I hope you can help me with this problem and let me know via email. Or > tell me where to look if this gets posted somewhere. In general, upgrading to 4.9.8.0 and then getting the 4.9.8.10 update is probably the best. > > Mahalo (Thank You), > Roger Furer > ra...@ha... > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click > _______________________________________________ > 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: Yellow_Yackets O. <sci...@ho...> - 2009-07-02 05:04:50
|
Hello, Well, I got tire of looking around on google... So, why not ask here, maybe someone will tell me the answer... How can I process HTTP requests using plain windows sockets. No external library. I just want to get the idea for learning purpose. Thanks _________________________________________________________________ Windows Live™: Keep your life in sync. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009 |
|
From: Yellow_Yackets O. <sci...@ho...> - 2009-07-02 16:39:31
|
Thanks for trying to answer but like i said... I really don't want to use no other external libraries like curl or chilkat or WinNet or any other... I want to know how does a server process HTTP requests by just using #include <winsock2.h> and no other winsock base libraries. _________________________________________________________________ Insert movie times and more without leaving Hotmail®. http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009 |
|
From: Yellow_Yackets O. <sci...@ho...> - 2009-07-02 20:22:14
|
Oh OK. Thanks again for your help. So... one question... because the recv function receives only string(char*); do I have to break it down to find the (for example) the 'GET' method then look after a space line to find what is requesting? _________________________________________________________________ Hotmail® has ever-growing storage! Don’t worry about storage limits. http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009 |
|
From: Johannes P. <joh...@pr...> - 2001-09-06 07:54:41
|
Lo there
------------
to start of you can get this answer at the DevC++ webpage in the FAQ
section. Secondaly
if you create a SIMPLE Dos ap from scratch you will see that it puts in a
template of code that has a
PAUSe line in it example :
//SNIP
#include <iostream.h>
#include <stdlib.h>
int main()
{
system("PAUSE");
return 0;
}
//END SNIP
this will pause the console window that comes up until you press enter or
soemthing.
This is a drag I must admit but is not a big problem really.
I hope it helps and I hope I understood correctly your problem
Johannes
At 07:33 06/09/2001 +0000, you wrote:
>Hi, I am having problems when I try to execute my programs.
>
>To start off, I am writing basic Console Applications. This is a basic
>application that I am trying to get to work.
>
>***********************************************
>
>#include <stdio.h>
>#include <iostream.h>
>
>int main(int argc, char *argv[])
>{
>int Age;
>
>cout << "What is your age?\n";
>cin >> Age;
>cout << "Your age is " << Age << " .\n";
>
> return 0;
>}
>
> Well, as you can see, I ask the user to imput their age. Then as
> soon as they do and press enter, you can see it display the cout string
> that tells them their age, but it only displays it for a second and then
> the window closes.
> My question was, is there a tag that I can add to keep it from
> closing the window immediatly? I am not sure if it just a bug, or I just
> have a missing string. But the reason I am confused is because I am
> taking a programming course at college, and we use Microsoft Visual
> C++. The only difference that I see is instead of the <stdio.h> tag at
> the top of the program, we use <stdafx.h>. Could this have anything to
> do with it, or is there just another string that this program uses that
> makes it finish answering the question and not just immediatly terminate
> the program.
>
>Any feedback you could give me would be greatly appreciative.
>Thank You,
>
>Brian Crabtree
>Reidsville NC
>
>
>_________________________________________________________________
>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
|