Docsity

Stringhe, concatenazione di stringhe, stringhe con indice, Switch stantement, Schemi e mappe concettuali di Informatica

Toggle sidebar
bg1
STRINGHE DI CARATTERI (Definizione, Utilizzo)
LE STRINGHE SONO SEQUENZE DI CARATTERI, IN ORDINE PRESTABILITO, UTILIZZATE
PER RAPPRESENTARE IL TESTO. VIENE AGGIUNTO ALLA STRUTTURA DEL
Esempio: Questo esempio manda a schermo la parola CIAO.
#include <iostream>
#include <string>
using namespace std;
int main()
{ string saluto="ciao";
cout<<saluto;
return 0;
}
CONCATENARE DUE STRINGHE PER CREARNE UNA NUOVA
Per concatenare due stringhe si utilizza l'operatore "+" , quest'ultimo somma le due
stringhe in input e restituisce una nuova stringa.
Esempio: Manda a schermo il nome completo "Mario Rossi".
#include <iostream>
#include <string>
using namespace std;
int main()
{
string nome="Mario";
string cognome="Rossi";
string Nomecompleto= nome + cognome;
cout<<Nomecompleto;
return 0;
}
pf3

Anteprima parziale del testo

Scarica Stringhe, concatenazione di stringhe, stringhe con indice, Switch stantement e più Schemi e mappe concettuali in PDF di Informatica solo su Docsity!

STRINGHE DI CARATTERI (Definizione, Utilizzo)

LE STRINGHE SONO SEQUENZE DI CARATTERI, IN ORDINE PRESTABILITO, UTILIZZATE

PER RAPPRESENTARE IL TESTO. VIENE AGGIUNTO ALLA STRUTTURA DEL

Esempio : Questo esempio manda a schermo la parola CIAO. #include #include using namespace std; int main() { string saluto="ciao"; cout< #include using namespace std; int main() { string nome="Mario"; string cognome="Rossi"; string Nomecompleto= nome + cognome; cout<

STRIGHE CON INDICE togliere.

ESEMPIO: Manda a video la lettera di indice 0. Int main() { string saluto="Ciao"; cout< #include using namespace std; int main() { string nome; cout<<"Inserisci il tuo nome: "; cin>>nome; cout<<"Il tuo nome è: "< using namespace std; C I A O POSIZIONE (^1 2 3 ) INDICE (^0 1 2 )