不能用全局变量和字符串的话,用c++咋写啊

输入一个句子,如果句子超过30个字,删掉标点符号,跳过一两个字符的单词,删掉句子里面的the 和 and 。

例如

输入: the a apple pan with sugar and vanilla

输出: apple pan with sugar vanilla

可以用cstrings

我尝试了用strlen 但是显示找不到我输入值

#include<iostream>
#include<cstring>
#include<vector>
using namespace std;

vector<string> split(string str, string pattern)
{
    string::size_type pos;
    vector<string> result;
    str += pattern; //扩展字符串以方便操作
    int size = str.size();
    for (int i = 0; i < size; i++)
    {
        pos = str.find(pattern, i);
        if (pos < size)
        {
            string s = str.substr(i, pos - i);
            result.push_back(s);
            i = pos + pattern.size() - 1;
        }
    }
    return result;
}

int main()
{
    string s;
    getline(cin, s);
	vector<string> result=split(s," ");
	for(int i=0; i<result.size(); i++){
		if (result[i].size()>2 && result[i]!="the" && result[i]!="and")
		   	cout<<result[i]<<" ";
	}
    return 0;
}

 


#include <cstdio>
#include <cstring>

void strtok_fun(char* src,char* &dst,const char* splitChar = " ")
{
    //printf("src:\"%s\", splitChar:\"%s\"\n", src, splitChar);
    memset(dst,0,sizeof(dst));
    char* ptr = strtok(src, splitChar);
    for(; ptr != NULL; )
    {
        if(strlen(ptr) ==1 
        || strlen(ptr)==2 
        || strcmp(ptr,"the")==0 
        || strcmp(ptr,"and")==0)
        {
            //printf("%s strlen(%s):%d 不合法\n", ptr,ptr,strlen(ptr));
            ptr = strtok(NULL, splitChar);
            continue;
        }
            
        strcat(dst," ");
        strcat(dst,ptr);
        printf("%s %d\n", ptr,strlen(ptr));
        
        ptr = strtok(NULL, splitChar);
    }
}

int main()
{
    char src[128] = " the a apple pan with sugar and vanilla";
    char* dst=new char[128];
    
    strtok_fun(src,dst);
    
    printf("dst:%s\n", dst);
    delete []dst;
    
    return 0;
}