С++ Помогите чайнику с ввводом данных с клавиатуры
Задание: Определить, есть ли любое из двух слов частью второго.
Это надо сделать с помощью строк.
Выполнить программу с разными выходными данными.
Текст вводится с клавиатуры.
Оригинальный текст и результаты должны быть выведены на экран.
Вот что у меня получилось:
#include
#include
#include
#include
#include
void comparison(int sizeofs1, int sizeofs2, char s1[sizeofs1], char s2[sizeofs2])
{
bool found = false;
if(strstr(s1, s2) != NULL)
{
found = true;
printf("s2 is a part of s1\n");
}
if(strstr(s2, s1) != NULL)
{
found = true;
printf("s1 is a part of s2\n");
}
if(!found)
{
printf("strings are not similar\n");
}
}
int main()
{
int sizeofs1;
int sizeofs2;
scanf("%d %d", &sizeofs1, &sizeofs2);
char *s1 = (char malloc(sizeofs1 * sizeof(char));
char *s2 = (char malloc(sizeofs2 * sizeof(char));
scanf("%s %s", s1, s2);
comparison(s1, s2);
getch();
}
Выдает ошибку:
1>------Build started: Project: Lab10, Configuration: Debug Win32 ------
1>Compiling...
1>Lab10.cpp
1>c:\users\елена\documents\visual studio 2005\projects\lab10\lab10\lab10.cpp(7) : error C2057: expected constant expression
1>c:\users\елена\documents\visual studio 2005\projects\lab10\lab10\lab10.cpp(7) : error C2466: cannot allocate an array of constant size 0
1>c:\users\елена\documents\visual studio 2005\projects\lab10\lab10\lab10.cpp(7) : error C2057: expected constant expression
1>c:\users\елена\documents\visual studio 2005\projects\lab10\lab10\lab10.cpp(7) : error C2466: cannot allocate an array of constant size 0
1>c:\users\елена\documents\visual studio 2005\projects\lab10\lab10\lab10.cpp(37) : error C2660: 'comparison' : function does not take 2 arguments
1>Build log was saved at "file://c:\Users\Елена\Documents\Visual Studio 2005\Projects\Lab10\Lab10\Debug\BuildLog.htm"
1>Lab10 - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Заранее спасибо за помощь!!!