C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pointeurs

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
Jean Pierre Daviau
Guest





PostPosted: Sat Feb 26, 2005 12:09 pm    Post subject: pointeurs Reply with quote



Bonjour à tous,

Le premier while s'exécute mais le deuxième crashe toujours.

J'ai tenté les possibilités suivantes:
*(Dest +1) = pArg[i];
*(Dest +1) += pArg[i];

et après avoir modifié la déclaration de Dest:
char Dest[1000];
Dest[t] = pArg[i];


===================
/* my.c "?name=me%20first&age=18" */
#include <stdio.h>

#pragma argsused
int main (int argc, char *argv[]){//

char *Dest;
char pArg[1000];
int i = 0;

while(argv[1][i] != '') {
pArg[i] = argv[1][i];
printf("%c ", argv[1][i]);
i++;
}
i = 0;
while( pArg[i] != '=' )
{
printf("while- %cn", pArg[i]);
i++;
}
i++;
while( pArg[i] != '&' )
{
if( pArg[i] != '+' )
{
*(Dest +1) = pArg[i];
}
else
*(Dest +1) = ' ';

i++;
}

printf("end- %sn", *Dest);

return 0;
}


--
Jean Pierre Daviau
--
http://jeanpierredaviau.com


Back to top
Fabien LE LEZ
Guest





PostPosted: Sat Feb 26, 2005 12:51 pm    Post subject: Re: pointeurs Reply with quote



On Sat, 26 Feb 2005 07:09:31 -0500, "Jean Pierre Daviau"
<Once (AT) WasEno (DOT) ugh>:

Quote:
#include
#pragma argsused
int main (int argc, char *argv[]){//

char *Dest;
char pArg[1000];

Erreur d'aiguillage. Soit tu programmes en C, et il faut poster sur
fr.comp.lang.c, soit tu programmes en C++, et il faut[*] utiliser
std::string (ou autre classe de chaîne).



[*] Bon, OK, on peut faire sans, de même qu'on peut programmer en
tournant le dos à l'écran.


--
;-)

Back to top
Pierre Maurette
Guest





PostPosted: Sat Feb 26, 2005 1:30 pm    Post subject: Re: pointeurs Reply with quote



Jean Pierre Daviau a écrit :
Quote:
Bonjour à tous,
[...]


Quote:
/* my.c "?name=me%20first&age=18" */
fr.comp.lang.c

C'est du C même pas caché.
[...]

Quote:
char *Dest;
Il faut initialiser ce pointeur. Par une fonction d'allocation, ou en le

remplaçant par un tableau comme vous le suggérez. Ce n'est pas
exactement équivaelnt.
[...]

Quote:
if( pArg[i] != '+' )
{
*(Dest +1) = pArg[i];
}
else
*(Dest +1) = ' ';

i++;
}
Là, il faut certainement un truc du genre: *(Dest + j++) ou Dest[j++].

Mais ce n'était pas ça qui faisait planter.
Et terminer par un *(Dest + j) + '' ou Dest[j++] = '' si j'ai bien
lu votre code.

Quote:
printf("end- %sn", *Dest);
Non.

printf("end- %sn", Dest);
--
Pierre

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.