
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String::at() Function in C++
In this section, we will see what is the at a () function in C++. The at() function is used to access the character at a given position.
In this program, we will iterate through each character using at a () function and print them into different lines.
Example Code
#include<iostream> using namespace std; main() { string my_str = "Hello World"; for(int i = 0; i<my_str.length(); i++) { cout << my_str.at(i) << endl; //get character at position i } }
Output
H e l l o W o r l d
Advertisements