can anyone help me convert my c program so it works on a linux system or mac? thank you.

#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
int c;
int a, b;
char d;
pov:system("cls");
printf("Enter the first number\n");
a=getch()-48;
system("cls");
printf("Enter the function:\n");
d=getch();
system("cls");
printf("Enter the second number\n");
b=getch()-48;
system("cls");
while (0==0)
{
if (d=='*')
{
a=a*b;
}
if (d=='/')
{
a=a/b;
}
if (d=='+')
{
a=a+b;
}
if (d=='-')
{
a=a-b;
}
printf("value is %d \n",a);
printf("Press 'q' to quit, or press other key to repeat data input\n");
c=getch();
if((c=='q')||(c=='Q')) return;
goto pov;
}
}
Member Avatar for GreenDay2001

> convert my c program so it works on a linux system or mac
Don't use any non standard functions. Dont use conio.h , since that is DOS library. So replace getch() with getchar() since later is standard funtion, though wont work exactly like former(you will have to hit enter). Dont use system("cls") . Again it is dos and windows specific.

never use conio.h for anything. that just breaks your program for anythign other than windows.

and never,.ever, ever use "GOTO" statements. and by that i mean never. they're absolutely horrid. use a while or for loop instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.