changed some stuff
This commit is contained in:
BIN
arrays/a.out
Executable file
BIN
arrays/a.out
Executable file
Binary file not shown.
9
arrays/array.cpp
Normal file
9
arrays/array.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string cars[4] = { "Volvo" , "Opel", "Volkswage" , "xyn" };
|
||||||
|
std::cout << cars[1];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
11
arrays/array_for.cpp
Normal file
11
arrays/array_for.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
string cars[4] = {"Volvo", "Opel", "Volkswagen", "Auto"};
|
||||||
|
|
||||||
|
for (int i = 0; i < 4 ; i++) { // needs to be size of cars array else segfault
|
||||||
|
cout << cars[i] << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
21
arrays/get_size.cpp
Normal file
21
arrays/get_size.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int return_byte_size() {
|
||||||
|
int number_array[10] = {1,2,3,4,5,6,7,8,9,10};
|
||||||
|
return sizeof(number_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
int return_length_of() {
|
||||||
|
int number_array[10] = {1,2,3,4,5,6,7,8,9,10};
|
||||||
|
return sizeof(number_array) / sizeof(number_array[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cout << return_byte_size() << "\n";
|
||||||
|
cout << return_length_of() << "\n";
|
||||||
|
cout << "Looping through";
|
||||||
|
cout << loop_sizeof() << "\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
10
arrays/sizeof_loop.cpp
Normal file
10
arrays/sizeof_loop.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int numbers[10] = {1,2,3,4,5,6,7,8,9,10};
|
||||||
|
for (int i = 0; i < sizeof(numbers) / sizeof(numbers[0]) ; i++) {
|
||||||
|
cout << numbers[i] << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user