If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Read string by words

I dont know how good you are going to undestand me:
I made an encryption program. It uses space between 2 letteres. Now I want to use the generated string and read every word at a time and convert it to a letter.
Here is the code:
// decript.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
using namespace std;

Re: Read string by words

Originally Posted by zorro59

Sorry, but I'll have to do mare reasearch regarding std::string ( what is the difference?).

std::string is a class wrapping a dynamic char array. In addition to handling all the tricky memory management internally so that you don't have to, it provides numerous operators which make string operations much more intuitive. Plus it removes the possibility of overwriting the array bounds that you get with fixed-size arrays.

The one thing it doesn't play well with is strtok. You can get equivalent functionality out of it with other methods, but since strtok changes the string in-place by inserting NULLs, you can't use it directly.