#include "stdafx.h" #include <iostream> using namespace std; int main() { char str[32] = { 0 }; int value = 0, i; cout << "Input: "; cin >> str; for (i=0;i<32;i++) { value += str[i]; } cout << "Output:" << value << endl; return 0; }
std::string
std::string str; cin >> str; for (size_t i = 0; i < str.length(); i++) { value += str[i]; } // Or since C++11 for (char& c : str) { value += c; }
for (i=0;i<strlen(str);i++)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)