fatal error: conio.h: No such file or directory

closed account (Nwb4iNh0)
Im trying to run this code but I get this error!
fatal error: conio.h: No such file or directory



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <conio.h>

#include <stdio.h>

void shellsorting(int a[], int n)

{

int i, j, k, tmp;

for (i = n / 2; i > 0; i = i / 2)

{

for (j = i; j < n; j++)

{

for(k = j - i; k >= 0; k = k - i)

{

if (a[k+i] >= a[k])

break;

else

{

tmp = a[k];

a[k] = a[k+i];

a[k+i] = tmp;

}

}

}

}

}

int main()

{

int a[30];

int k, n;

printf("total no. of elements : ");

scanf("%d", &n);

printf("\nEnter %d numbers: ", n);

for (k = 0 ; k < n; k++)

{

scanf("%d", &a[k]);

}

shellsorting(a, n);

printf("\n Sorted array is: ");

for (k = 0; k < n; k++)

printf("%d ", a[k]);

return 0;

} 
Why are you including <conio.h>? You don't use any of the functions contained in that ancient and VERY non-standard header.

Your code formatting looks like a huge plate of cooked pasta and sauce thrown against a wall. ICK! You really should try to make it READABLE.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>

void shellsorting(int a[], int n)
{
   int i, j, k, tmp;

   for (i = n / 2; i > 0; i = i / 2)
   {
      for (j = i; j < n; j++)
      {
         for (k = j - i; k >= 0; k = k - i)
         {
            if (a[k + i] >= a[k])
               break;
            else
            {
               tmp = a[k];
               a[k] = a[k + i];
               a[k + i] = tmp;
            }
         }
      }
   }
}

int main()
{
   int a[30];
   int k, n;

   printf("total no. of elements : ");
   scanf("%d", &n);

   printf("\nEnter %d numbers: ", n);

   for (k = 0; k < n; k++)
   {
      scanf("%d", &a[k]);
   }

   shellsorting(a, n);

   printf("\n Sorted array is: ");

   for (k = 0; k < n; k++)
      printf("%d ", a[k]);

   return 0;
}
closed account (Nwb4iNh0)
thanks for your help :)
You didn't answer my question:
me wrote:
Why are you including <conio.h>?

I doubt I'm gonna like the answer. Probably something along the lines of "I found the code on the internet and don't know what it is supposed to do."

Please contradict me.
closed account (Nwb4iNh0)
main idea in my question is is to solve the conio.h header file on Linux system despite the struction of this code, coz I face this problem while using other libraries specially openGL and sfml, but yet I cant find answer on the internet for this problem, I just want to know how to fix (no such file or directory) , thats it
TeleMark wrote:
main idea in my question is is to solve the conio.h header file on Linux system


Main idea in my answer is to convince you that:
(1) Nothing in your code uses conio.h
(2) It's an ancient, non-standard library used (mainly) for MS-DOS terminals and so not likely to be much use on linux
(3) It's a waste of time searching for libraries that you aren't going to use.

Topic archived. No new replies allowed.