I wrote this C program for Win32/c compiler but while i'm trying run this using gcc in Linux machine or codepad.org it shows 'conio.h: No such file or directory compilation terminated' What are modification to be done to execute this program without including any other new includes like curses.h
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,j=0,k=0,n,u=0;
char s[100],c2,c[10];
char c1[3]={'a','b','c'};
clrscr();
printf("no of test cases:");
scanf("%d",&n);
for(u=0;u<n;u++)
{
printf("Enter the string:");
scanf("%s",s);
i=0;
while(s[i]!='\0')
{
if(s[i+1]=='\0')
break;
if(s[i]!=s[i+1])
{
for(j=0;j<3;j++)
{
if((s[i]!=c1[j])&&(s[i+1]!=c1[j]))
{
c2=c1[j];
}
}
s[i]=c2;
for(k=i+1;k<100;k++)
{
s[k]=s[k+1];
}
i=0;
}
else
i++;
}
c[u]=strlen(s);
}
for(u=0;u<n;u++)
printf("%d\n",c[u]);
getch();
}
I did not look at your code to see if it needs the three functions. But this is the simplist way to get them. There is normaly a better way than using getch(). clrscr() is also no fun when you clear my screen !
#include<stdio.h>
#include <stdlib.h> // system
#include <string.h> // strlen
#include <termios.h> // getch
#include <unistd.h> // getch
void clrscr()
{
// Works on systems that have clear installed in PATH
// I don't like people clearing my screen though
system("clear");
}
int getch( )
{
struct termios oldt, newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}