#include <iostream.h>
#include <string.h>
void menu_choice();
void char_count(char[], char);
char* concatenating_function(char*, char*);
int main()
{
char continue_input;
char char_to_count=0;
do {
menu_choice();
cout<<"Do you want to continue?\n";
cin>>continue_input;
}while (continue_input == 'y' || continue_input == 'Y');
return 0;
}
void menu_choice (void)
{
char word_to_use[30];
char char_to_count;
int user_input = 0;
cout<<"Menu Choice \n";
cout<<"==============================\n";
cout<<"1-Count Character \n";
cout<<"2-Copy String \n";
cout<<"==============================\n";
cout<<" Please Enter your selection \n";
cin>>user_input;
switch (user_input)
{
case 1:
cout<<"Please Enter String\n";
cin>>word_to_use;
cout<<"Please Enter letter to Count\n";
cin>>char_to_count;
void char_count(char word_to_use[], char char_to_count);
break;
case 2:
char* concatenating_function(char* pointer_1, char* pointer_2);
break;
default:
cout<<"Input Error.";
}
}
void char_count(char word_to_use[], char char_to_count)
{
int times = 0;
char* ch_ptr;
*ch_ptr = word_to_use[0];
while (*ch_ptr != char_to_count)
{
++times;
++ch_ptr;
}
cout<<"The Letter " << char_to_count <<" was used: " << times << " times\n";
}
char* concatenating_function(char* pointer_1, char* pointer_2)
{
char* return_ptr;
char string_1[30];
char string_2[30];
char conct_string[60];
char* string_cat_ptr;
cout<<"Please Enter First String\n";
cin.getline(string_1, 30);
cout<<"Please Enter Second String\n";
cin.getline(string_2, 30);
strcpy(conct_string, string_1);
string_cat_ptr[strlen(conct_string)];
strcpy(string_cat_ptr, string_2);
string_cat_ptr = conct_string;
return_ptr = string_cat_ptr;
return return_ptr;
}

First do not call a function when it has already been delclared by its prototype:

void char_count(char word_to_use[], char char_to_count);
char* concatenating_function(char* pointer_1, char* pointer_2);

i.e Corrct way to call:
char_count(word_to_use[], char_to_count);

plus you have some unintialized variables
'ch_ptr' used without having been initialized
'string_cat_ptr' used without having been initialized

then you need a break statement after default (good etiquite).

Once you call the methods and pass the data correctly it should work.

This article has been dead for over six months. Start a new discussion instead.