Let me start by pointing out what is wrong with your code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <map>
using namespace std;
int jomleTokalame(string *a,string c,int count) {
string cc="";
count =0;
for(int i = 0 ; c[i]!='\0';i++){
cc+=c[i];
if (c[i]==' ' || c[i+1]=='\0'){
a[count]=cc;
count++;
cc="";
}
}
return count;
}
int _tmain(int argc, _TCHAR* argv[]) {
int location[100];
string str[100];
string a[100];
string s;
int n,i=1,j,k=0,g;
cout<<"plz enter number of lines:\n";
cin>>n;
for(i=1;i<=n;i++) {
getline(cin,a[i],'\n');
s=a[i];
g=jomleTokalame(str,s,0);
for(j=0;j<=g;j++)
cout<<str[j];
}
getch();
return 0;
}
Now that you know what is wrong. Lets look at the same solution that is much better:
#include <iostream>
#include <conio.h>
#include <string>
using std::cout;
using std::cin;
using std::string;
int jomleTokalame(string *strWords, const string &strLine) {
int nWords = 0;
strWords[nWords]="";
for(int nChar = 0; strLine[nChar] != '\0'; ++nChar){
strWords[nWords] += strLine[nChar];
if (strLine[nChar] == ' ' || strLine[nChar + 1] == '\0'){
strWords[++nWords]="";
}
}
return nWords + 1;
}
int _tmain(int argc, _TCHAR* argv[]) {
string strWords[100];
string *strLines = NULL;
int nLines, nLine, nWords, nWord;
cout << "plz enter number of lines:\n";
cin >> nLines;
strLines = new string[nLines];
for (nLine = 0; nLine < nLines; ++nLine) {
getline(cin, strLines[nLine], '\n');
nWords = jomleTokalame(strWords, strLines[nLine]);
for (nWord = 0; nWord < nWords; ++nWord)
cout << strWords[nWord];
}
delete[] strLines;
_getch();
return 0;
}