File tree Expand file tree Collapse file tree 3 files changed +76
-62
lines changed
Expand file tree Collapse file tree 3 files changed +76
-62
lines changed Original file line number Diff line number Diff line change 1- # executable files
2- assign1
3- ioexample
4- * .
1+ # Executables
2+ * .exe
3+ * .out
4+ * .app
5+ *
6+ ! /** /
7+ ! * . *
58
69# Compiled Object files
710* .slo
811* .lo
912* .o
13+ * .obj
14+ * .dSYM /
15+
16+ # Precompiled Headers
17+ * .gch
18+ * .pch
1019
1120# Compiled Dynamic libraries
1221* .so
1322* .dylib
23+ * .dll
24+
25+ # Fortran module files
26+ * .mod
27+ * .smod
1428
1529# Compiled Static libraries
1630* .lai
1731* .la
1832* .a
33+ * .lib
1934
20- # VS stuff
21- build
22- ipch
23- * .sdf
24- * .opensdf
25- * .suo
26- * .vcxproj
27- * .vcxproj.filters
28- * .sln
29-
30- # VIM stuff
35+ # Temporary files
36+ ~ *
37+ * .tmp
38+ * .swo
3139* .swp
3240
33- # Xcode stuff
34- build_xc
35-
36- * .user
37- * .user. *
38- * ~
39-
40- # build system
41- build. * /
42- extdep /install
43- extdep /download
44-
45- * .pyc
46-
47- # MacOS Development
48- .DS_Store
49- # CocoaPods
50- Pods /
51- Podfile.lock
52- # Xcode
41+ # Mac
5342.DS_Store
54- build /
55- * .pbxuser
56- ! default.pbxuser
57- * .mode1v3
58- ! default.mode1v3
59- * .mode2v3
60- ! default.mode2v3
61- * .perspectivev3
62- ! default.perspectivev3
63- * .xcworkspace
64- ! default.xcworkspace
65- xcuserdata
66- * .xcuserstate
67- profile
68- * .moved-aside
69- DerivedData
70- project.pbxproj
71-
72- # JetBrains stuff
73- .idea /
74-
75- doc /html
76- * .autosave
77- node_modules /
78-
79- dependency_graph.svg
Original file line number Diff line number Diff line change @@ -30,4 +30,12 @@ Some basic differences between C and C++
3030 * ` <vector> `
3131 * ` const ` instead ` define `
3232 * ` inline `
33-
33+
34+ #### Dynamic Array
35+ Create multidimensional arrays dynamicaly
36+
37+ * File:
38+ * dyn-array.cpp
39+ * Subjects
40+ * ` new ` and ` delete ` chuncks of memory
41+ * pointers to array
Original file line number Diff line number Diff line change 1+ //
2+ // This program shows an example to create multidimensional arrays in C++
3+ //
4+ // Especificaly in this example, you can see a 2D array.
5+ //
6+
7+ #include < iostream>
8+
9+ int main () {
10+
11+ // Defining dimensions
12+ int N = 3 ;
13+ int M = 3 ;
14+
15+ // Creating the matrix
16+
17+ double ** mtrx = new double *[N];
18+ for (int i = 0 ; i < N; ++i)
19+ mtrx[i] = new double [M];
20+
21+ // Fill the matrix
22+
23+ for (int i = 0 ; i < N; ++i)
24+ for (int j = 0 ; j < M; ++j)
25+ mtrx[i][j] = (double )(i) + ((double )(j)/100 );
26+
27+ // Display the result
28+
29+ std::cout << ' \n ' << " ---------------------------" << ' \n ' ;
30+ for (int i = 0 ; i < N; ++i) {
31+ for (int j = 0 ; j < M; ++j)
32+ std::cout << mtrx[i][j] << ' \t ' ;
33+ std::cout << ' \n ' ;
34+ }
35+
36+ // Free memory
37+ for (int i = 0 ; i < N; ++i)
38+ delete [] mtrx[i];
39+
40+ delete [] mtrx;
41+
42+ return 0 ;
43+ }
You can’t perform that action at this time.
0 commit comments