Passez un tableau a une fonction ?

FeelCode Messages postés 278 Date d'inscription vendredi 16 avril 2004 Statut Membre Dernière intervention 27 avril 2006 - 9 avril 2006 à 16:49
luhtor Messages postés 2023 Date d'inscription mardi 24 septembre 2002 Statut Membre Dernière intervention 28 juillet 2008 - 9 avril 2006 à 17:19
//Fichier 1
#include
#include <string>
//#using <mscorlib.dll>
//using namespace System;

//Fichier du projet
#include "MainPrototype.h"
#include "AffichageConsole.h"
#include "Mainfunction.h"

using namespace std;

std::string FullInfo(std::string* tab, int size);
int main()
{
// Tableau en local
string TabTextInfo[30];
string TabTextAces[29];
string TableauMix();

CP("******************************************");
CP("Bienvenue dans total memo c++ Vertion 1.05");
CP("******************************************");

//remplissage note : peut ce faire avec un fichier !
TabTextInfo[0]="bool : 2 valeur possible true et false";
TabTextAces[0]="$bool";
TabTextInfo[1]="char : Un type de caractère pouvant contenir des valeurs ASCII";
TabTextAces[1]="$char";
TabTextInfo[2]="short : Entier de : -32 768 A 32767";
TabTextAces[2]="$short";
TabTextInfo[3]="int : Entier de : -2 147 483 648 A 2 147 483 647";
TabTextAces[3]="$int";
TabTextInfo[4]="long : Un type de données entier equivalant a [int] sauf quîl a une taille double avec la plupart des compilateur dans visual c++ la valeur est identique a [int]";
TabTextAces[4]="$long";
TabTextInfo[5]="__int8 : Un type specifique de Microsoft corespondat aux type [char]";
TabTextAces[5]="$__int8";
TabTextInfo[6]="__int16 : Un type specifique de Microsoft corespondat aux type [short]";
TabTextAces[6]="$__int16";
TabTextInfo[7]="__int43 : Un type specifique de Microsoft corespondat aux type [int]";
TabTextAces[7]="__int43";
TabTextInfo[8]="__int64 : Un type specifique de Microsoft : -2^63 A 2^63-1 ";
TabTextAces[8]="__int64";
TabTextInfo[9]="&& : opérateur logique servant a associer 2 comparer deux instructions, ex de syntaxe : if (2+2 && 2-1){} ";
TabTextAces[9]="$&&";
TabTextInfo[10]="Tableau de type string la limite supereieur est de 67 108 863 note il peut probable que l' Os supporte une valeur aussi grande, 37 108 863 = environ 1,5 Go de memoire";
TabTextAces[10]="$Tableau";
TabTextInfo[10]="Tableau et fonction : Une fonction peux recevoire un tableau mai ne peu renvoiyer un tableaux";
TabTextAces[10]="$Tableau";
TabTextInfo[12]="Variable : Déclarer une variable de type string : string M=teste avec deux guilmet";
TabTextAces[12]="$Variable";
TabTextInfo[13]="Prototype : La diference entre un prototype et une fonction ou un type void = (sub): le point virgule";
TabTextAces[13]="$Prototype";
TabTextAces[14]="$Liste";
TabTextAces[15]="$ComListe";
TabTextAces[16]="$help";

FullInfo(TabTextInfo,30);
CP(TableauMix());
cin.ignore();
return 0;
}
//FICHIER 2

#include
#include <string>

using namespace std;

//PROTOTYPE des fonctions du projet.
// Ne renvoie aucune valeur.
void FournireInfo(const string Utile);
//renvoiye un type string
std::string FullInfo(std::string* tab, int size);
//FICHIER 3
#include
#include <string>
using namespace std;

//prototype
void CP(const string PrintConsol);

// Affichage simple
void CP(string PrintConsol)
{
cout << PrintConsol << endl;
}
//FIchier 4
#include
#include <string>
#include "MainPrototype.h"
using namespace std;

string TableauMix()
{
//string* MyCopy = new string[10];
//MyCopy[0] = string M;

return "Fin de l'exemple";
}

string FullInfo(string TabTextInfo, int Taille)
{
//declaration d'une variable string
string Buff;
//exemple de la boucle for
for (int CompteurA = 1;CompteurA <= Taille;CompteurA++)
{
Buff=TabTextInfo[CompteurA];
CP(Buff);
}
return "";
}

Erreur :
------ Début de la génération : Projet : CommandC, Configuration : Debug Win32 ------
Compilation en cours...
CommandCplusplus.cpp
Compilation du manifeste en ressources en cours...
Édition des liens en cours...
CommandCplusplus.obj : error LNK2019: symbole externe non résolu "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl FullInfo(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,int)" (?FullInfo@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAV12@H@Z) référencé dans la fonction _main
E:\Prog visual studio net\Function\CommandC\CommandC\Debug\CommandC.exe : fatal error LNK1120: 1 externes non résolus
Le journal de génération a été enregistré à l'emplacement "file://e:\Prog visual studio net\Function\CommandC\CommandC\Debug\BuildLog.htm"
CommandC - 2 erreur(s), 0 avertissement(s)
======== Génération : 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========

Quelqu'un peut il me donne le code qui fonctionne ?

Merci pour vos réponsse

Souriez vous ête lu [8D]

1 réponse

luhtor Messages postés 2023 Date d'inscription mardi 24 septembre 2002 Statut Membre Dernière intervention 28 juillet 2008 6
9 avril 2006 à 17:19
Avant de poster sur un forum lis 2 min ton code.

Tu vois bien que la définition de FullInfo et son implémentation sont différentes, comment veux tu que ca marche...

Et puis comment veux tu que le compilo s'en sorte, tu as deux définitions identiques pour la meme fonction...



Et pk tu mets ca dans ton fichier 1: std::string FullInfo(std::string* tab, int size);

Puisque la définition est dans le fichier2.

Et enfin, ca a l'air d'etre le gros boxon dans tes 3 fichiers, tu as
des définitions et implémentations dans chaque. Quel est le nom de
chacun des fichiers ?
0
Rejoignez-nous