使用指针不区分大小写搜索子字符串

时间:2017-03-22 13:29:55

标签: c++ pointers search

这是我到目前为止所做的。我无法将子字符串与句子进行比较 请帮助我找到将子字符串与句子进行比较的命令

#include<iostream>
#include<stdlib.h>
#include<stdio.h>

using namespace std;

int main()
{
    char *arr[3] = { NULL, NULL, NULL };


/*
 * block for entering names and storing names dynamically
 */
char sentnc[256]="";
cout << "enter the sentence ";
cin>>sentnc;
arr[0] = (char *) malloc(sizeof(char) * (strlen() + 1));

for (int i = 1; i <= 3; i++)
{
    char str[256] = "";
    cout << "enter word to be searched ";
    cin >> str;

    names[i] = (char *) malloc(sizeof(char) * (strlen(str) + 1));
    if (names[i] != NULL)
    {

0 个答案:

没有答案