Skip to content

Commit

Permalink
Added program on dynamical alloc. of memory and input from c-line
Browse files Browse the repository at this point in the history
  • Loading branch information
erikasan committed Aug 31, 2019
1 parent c4cbf15 commit 086ea13
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
15 changes: 15 additions & 0 deletions dynamicalallocationofmemory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;


double* b = new double[n]; // Using this approach, we do not
// have to declare n as constant

return 0;
}
11 changes: 11 additions & 0 deletions inputfromcommandline.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) // Add this rubbish to main
{
// argv[0] is the program name
// arg[1] is the first argument
// arg[2] is the second argument and so on
return 0;
}
14 changes: 10 additions & 4 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
using namespace std;


int func(int, int);

int main()
{
const int n = 5;
double b[n] = {};

n = 2;
}
int a = 1, b = 2;
cout << func(a, b);
return 0;
}

int func(int a, int b)
{
return a + b;
}

0 comments on commit 086ea13

Please sign in to comment.