1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
//ajouter une chaine formatée au bout d'une chaine existante
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//string s1 = s2.substr(posdeb,posfin);
//int ichform1,lonchform1=chform1.size(); //int iunechaine, tailleunechaine = unechaine.size ();
string tabul(int posatabuler,string precedente,string form,string nouvelle)
{//fc tabul
cout<<"---------------"<<endl;
int iprecedente,lonprecedente=precedente.size();
cout<<" precedente:"<<precedente<<"("<<lonprecedente<<")"<<endl; //controle de ch.precedente
string racourcie; //init ch.racourcie var.locale
racourcie=precedente.substr(0,posatabuler); //construction de ch.racourcie
int iracourcie,lonracourcie=racourcie.size();
cout<<" racourcie:"<<racourcie<<"("<<lonracourcie<<")"<<endl;
nouvelle=racourcie+form; //construction de ch.nouvelle
int inouvelle,lonnouvelle=nouvelle.size();
cout<<" nouvelle:"<<nouvelle<<"("<<lonnouvelle<<")"<<endl;
cout<<"---------------"<<endl;
return nouvelle;
}//fc tabul
int zer;
string echelled=": 1 2 3 40 colonnes";
string echelleu=":1234567890123456789012345678901234567890";
int posatabulerI=5; //position où on doit concaténer la chaine formI..
string precedenteI="1234567890123456789012345678901234567890"; //..sur la chaine precedenteI
string formI="FormUVWXYZ"; //la chaine de longueur toujours fixe,ici 10 car.
int main()
{
string nouvelleI;
string tabultabul;
tabultabul = tabul(posatabulerI,precedenteI,formI,nouvelleI);
cout<<" nouvelle:"<<nouvelleI<<"|<<<<<"<<endl;
cout<<" "<<endl;
cout <<"0/q"<<endl;
cin>>zer;
} |
Partager