HI I was writing a program that passes a string into an array, reverses the string, and passes to another array.
Half way done with my function definition I compiled and got some errors, that I am not able to understand. Here is my code:
// Hw-4_Bhasin.cpp : Defines the entry point for the console application.
void rev_str(void);
double Mean(const int Data[5][4], int, int);
void frequency(const int Data[5][4], int, int);
#include "stdafx.h"
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
char option;
cout<<"\n Please choose from the given menu.";
cout<<"\n R{Reverse String] M[Matrix] Q[Quit]."<<endl;
cin>> option;
switch(option)
{
case 'R':
rev_str();
break;
case 'r':
rev_str();
break;
}
system("pause");
return 0;
}
void rev_str(void)
{
const int MAX = 100;
char Input_String[MAX];
cout<<"Please enter a string."<<endl;
cin.get(Input_String, MAX);
cout<<Input_String;
for(int i=0; i<MAX; i--)
cout<<Input_String<<endl;
system("pause");
return;
}
The error states that' 'rev_str' identifier not found. In other words it does not tecognize the two function calls in the switch statements rather it is reading it as some sort of variable.
To overcome this I made the function prototypr local. After doing that, the program compiles, but on running the program when I hit r or R, the screen blanks out.
How can I resolve this.
Any help is appreciated.
Thanks.