//my first programming project
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string thanos, ultron;
int rogers, stark, logan, i;
rogers = 0;
stark = 0;
logan = 0;
i = 0;
do
{
cout << "please enter the first string: ";
cin >> thanos;
for (i = 0; thanos [i] != '\0'; i++)
rogers++;
cout << "the length of the first string is: " << rogers << endl;
cout << "please enter the second string: ";
cin >> ultron;
for (i = 0; ultron [i] != '\0'; i++)
stark++;
cout << "the length of the second string is: " << stark << endl;
; }
while (stark > rogers);
if(thanos[i]==ultron[logan])
cout<<"Substring found at position: ";
else
cout<<"Substring not found";
return 0;
}
hi guys im relatively new to programming...I just want to know what can I add or change so the computer can find the second string (ultron) in the first string (thanos) if any symbols of the second string match the first string...it has to be done without using built in library functions too...
for example the computer would output "substring found at position: " if any symbols of second string match first string or computer would output "substring not found" if no match
if(thanos[i]==ultron[logan])
every time the do while loop exits, the value of i here would be the size of the number of ultron word minus 1.
and logan is always 0