I have problem with char in my code, please guide me (c++).
I have this error: Run-Time Check Failure #3 - The variable 'op' is being used without being initialized
. What does it mean and how do I fix it?
This is my code:
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
using namespace std;
enum Operations {SIN1, COS1, TAN1};
void selectenteroperation(char *szInput) {
char *szLabels[3] = {"sin", "cos", "tan"};
int i=0;
while(strcmp(szInput,szLabels[i])==0)
++i;
switch (i)
{
case SIN1: { cout<<"SIN"; break; }
case COS1: { cout<<"COS"; break; }
case TAN1: { cout<<"TAN"; break; }
default: { cout<<"Wrong"; break; }
}
}
void main() {
char *op;
cout<<"op?";
cin>>op;
if(strcmp(op,"sin")==0) selectenteroperation("sin");
if(strcmp(op,"cos")==0) selectenteroperation("cos");
if(strcmp(op,"tan")==0) selectenteroperation("tan");
}