How to rewrite following C++ code into C code?

How to do this in C? Please write entire code, because general hints don't help me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  #include <iostream>
using namespace std;
int main(){
double**ptr= new double*[2];
for(int i=0;i<2;++i)
    ptr[i] =new double[2];
ptr[0][0]=76.65;    ptr[0][1]=6.45;
**(ptr+1)=3.7;    ptr[1][1]=2.0;

cout<<*ptr[0]<<"  "<<*(*ptr+1)<<endl;
cout<<**(ptr+1)<<"  "<<*(*(ptr+1)+1)<<endl;
return 0;
}
Last edited on
Well, there is no new keyword in C. std::cout does not exist in C.
The code is not totally flawless, you forget to delete the arrays you allocated before exiting the program.

+ Just change std::cout to printf().
+ Just change new to malloc() and free().
I still don't know how to do this, please write entire code. I'm a beginner as you can see.
Topic archived. No new replies allowed.