Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Inleiding tot String | Variabelen en Gegevenstypen
C++ Introductie
course content

Cursusinhoud

C++ Introductie

C++ Introductie

1. Aan de Slag
2. Inleiding tot Operatoren
3. Variabelen en Gegevenstypen
4. Introductie tot Programmastroom
5. Introductie tot Functies

book
Inleiding tot String

Je kunt tekst opslaan in variabelen met behulp van het string type. Om dit te doen, moet je de string bibliotheek opnemen, gebruik maken van de std namespace scope resolutie, en een variabele van het string type declareren. Dit stelt je in staat om naadloos reeksen van tekens in je programma's te verwerken.

cpp

main

copy
1234567891011
#include <iostream> #include <string> int main() { // Declaring string variable std::string text = "codefinity"; // Displaying string variable std::cout << text << std::endl; }

Strings variabelen kunnen ook nummers bevatten (als tekst). Het is echter belangrijk op te merken dat hoewel je nummers in dit formaat kunt opslaan, je niet direct wiskundige bewerkingen op deze nummers kunt uitvoeren terwijl ze als strings zijn opgeslagen.

cpp

main

copy
12345678910
#include <iostream> #include <string> int main() { std::string text = "1024"; // Displaying string variable std::cout << text << std::endl;; }

Als je probeert twee string-variabelen op te tellen, krijg je een concatenatie (het werkt zonder spaties). Hetzelfde gebeurt met nummers – ze worden niet algebraïsch opgeteld.

cpp

main

copy
1234567891011
#include <iostream> #include <string> int main() { std::string first_part = "Hello "; //space is also a symbol std::string second_part = "World"; //displaying the sum of string variables std::cout << first_part + second_part << std::endl; }
question mark

Wat is er mis met de onderstaande code?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4

Vraag AI

expand
ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

course content

Cursusinhoud

C++ Introductie

C++ Introductie

1. Aan de Slag
2. Inleiding tot Operatoren
3. Variabelen en Gegevenstypen
4. Introductie tot Programmastroom
5. Introductie tot Functies

book
Inleiding tot String

Je kunt tekst opslaan in variabelen met behulp van het string type. Om dit te doen, moet je de string bibliotheek opnemen, gebruik maken van de std namespace scope resolutie, en een variabele van het string type declareren. Dit stelt je in staat om naadloos reeksen van tekens in je programma's te verwerken.

cpp

main

copy
1234567891011
#include <iostream> #include <string> int main() { // Declaring string variable std::string text = "codefinity"; // Displaying string variable std::cout << text << std::endl; }

Strings variabelen kunnen ook nummers bevatten (als tekst). Het is echter belangrijk op te merken dat hoewel je nummers in dit formaat kunt opslaan, je niet direct wiskundige bewerkingen op deze nummers kunt uitvoeren terwijl ze als strings zijn opgeslagen.

cpp

main

copy
12345678910
#include <iostream> #include <string> int main() { std::string text = "1024"; // Displaying string variable std::cout << text << std::endl;; }

Als je probeert twee string-variabelen op te tellen, krijg je een concatenatie (het werkt zonder spaties). Hetzelfde gebeurt met nummers – ze worden niet algebraïsch opgeteld.

cpp

main

copy
1234567891011
#include <iostream> #include <string> int main() { std::string first_part = "Hello "; //space is also a symbol std::string second_part = "World"; //displaying the sum of string variables std::cout << first_part + second_part << std::endl; }
question mark

Wat is er mis met de onderstaande code?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4
Onze excuses dat er iets mis is gegaan. Wat is er gebeurd?
some-alt