hi!! can someone help me out?
im trying to make a program using a Recursive function.
in the main(). my program asks the user to enter 2 strings (2 words) and then sends them to the recursive function and there the function outputs the longest word of the two.
so im having trouble with my NULL and '/o' (since i made a string) and when i ask the user to input the second word my program closes!!! im getting really frustrated! =(
PLEASE help!!
#include <iostream>
#include <string.h>
using namespace std;
//this function is supposed to get both strings and decide which one is longer
char * longer(int * st1, int * st2, int i){
if(st1[i]=='/o' || st2[i]=='/0'){
if(st2[i]=='/0')
cout<<st1;
else if (st1[i]=='/0')
cout<<st2;
else
cout<<st2;
return 0;
}
else
longer(st1,st2,++i);
}
int main(){
int st1[15];
int st2[15];
int i=0;
cout<<"enter 2 strings:"<<endl;
cout<<"st1"<<endl;
cin>>st1[15];
cout<<"str2"<<endl;
//when the program gets here it simply stops working! honestly dont understand why!!
cin>>st2[15];
longer(st1,st2,i);
true!! THANKS haha beginners mistakes!
but i still have a problem with my cin>>st2[15]!
for some reason as soon as the program hits that it stops working (before even touching the function!)