Hi again.
I'm having two issues with this code, first of then strlen only counts the characters in the first word of the line I put into console. Then the second one is that the console takes the second word put into the console in to next "cin" and does not ofcourse then stop after asking for the second text since it has it already from the first input.
Ok I guess I can solve the input problem with clearing the memory between lines but what about the strlen issue then.
Here is the current code.
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <cstring>
#include <cstdlib>
#include <iostream>
using namespace std;
int count (char[]);
void strCopy (char[]);
int _tmain(int argc, _TCHAR* argv[])
{
char pszString[256];
char pszSource[256];
int size = 0;
cout << "Write a text that is under 256 characters = pszString" << endl;
cin >> pszString;
size = count(pszString);
cout << "Your text is " << size << " characters long." << endl;
cout << "Write another text that is under 256 characters = pszSource" << endl;
cin >> pszSource;
strCopy(pszSource);
return 0;
}
int count ( char pszString[] )
{
int size;
size = strlen(pszString);
return (size);
}
void strCopy(char pszSource[])
{
char pszDestination[256];
strcpy (pszDestination,pszSource);
cout << "The text in pszDestination is now " << pszDestination << " which should be the same you entered for pszSource" << endl;
system("PAUSE");
}
Please advice.