Please Help me understand my errors

Getting some logical errors

Page 1 of 1

1 Replies - 638 Views - Last Post: 19 October 2008 - 08:01 PM Rate Topic: -----

#1 jingoria  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 96
  • Joined: 22-October 07

Please Help me understand my errors

Post icon  Posted 19 October 2008 - 07:36 PM

I was writing a program that would pass a string to an array, reverse the string and then pass it to another array.
Half way through I compiled my program and getting some weird output.
My code so far is:
// 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"
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;

	case 'R':
	case 'r':

	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);


	for(int i=0; i<MAX; i--)


When declaring all my functions as global, I get 2 errors state that 'rev_str': identifier not declared. In other words it does not recognize my call to the function in the switch statement.

So I simply, placed a function prototype inside the main(). After this when I execute my program, it asks me for my option. When I press r or R, the screen blanks out. Seems like the compiler does not even reads the function definition.

What can I do?
Please help me.


Is This A Good Question/Topic? 0
  • +

Replies To: Please Help me understand my errors

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6237
  • View blog
  • Posts: 24,002
  • Joined: 23-August 08

Re: Please Help me understand my errors

Posted 19 October 2008 - 08:01 PM

Put a cin.ignore() after your cin >> option to get rid of the newline that's stuck in the buffer.

Also, this loop is's infinite. Think about it.
for(int i=0; i<MAX; i--)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1