problem with process.h under Ununtu

I'm pretty new at C++.
Just trying to do few lessons. Some of them completed succeful, but last one...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;
#include <process.h>

int main () {
    int n,i;
    cout << "Enter nn";
    cin >> n;
    for (i=2;i<n/2;i++) {
        if (n%i == 0) {
            cout << "N can devided tp" << i << "n";
            exit(0);
        }
    }

    return 0;
}

trying to compile it:
roman@admin:~/Documents/c/newtry$ g++ l3.c
l3.c:3:21: error: process.h: No such file or directory
l3.c: In function
#include <stdlib.h>
If u add this header run ur codes.And mustn't process.h
I'm pretty sure you don't need process.h, but you do need stdlib.h/<cstdlib> to use exit() and declare 'using namespace' after you've declared all your include files
Last edited on
Thanks a lot!
Are any tables with lists of fuctions attached to certain library for Unix / Windows.
You can start here: http://www.cplusplus.com/reference/clibrary/, the kind of tables you talked about are usually found in textbooks, I think
thanks a lot, but again a trouble .
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
char c;
int i=0;
cout << "Enter the line till Enter key\n";
while ((c=getche())!='\n') {
i++;
}
cout <<i<<"\n";
return 0;
}


l4.c:2:19: error: conio.h: No such file or directory
l4.c: In function ‘int main()’:
l4.c:11: error: ‘getche’ was not declared in this scope
But i inlcuded all need to work, as i seen at example (
Last edited on
conio.h is non-standard. You'll have to find a different function that is standard to do what you want.

Take a look at these: http://www.cplusplus.com/doc/tutorial/basic_io/
It's best you avoid stuff like conio.h to begin with, unless you really, really need to (which is basically only when you need extraordinarily fancy console applications, for which the only justification I can think of right now would be you want to develop a roguelike. Other than that, just make it a GUI application). Instead of using random nonstandard C-style functions like getch(), getche() or stuff like that, use iostreams like cin. You already use the ostream cout, it will only hurt your consistency if you don't also use an istream like cin for input.
thank all for answer!
Topic archived. No new replies allowed.