1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-24 02:16:19 +04:00
osblog/risc_v/userspace/helloworld.cpp

21 lines
568 B
C++
Raw Normal View History

#include <cstdio>
2020-05-23 00:29:44 +04:00
const int SIZE = 100000;
double myarray[SIZE];
int another_array[5] = {1, 2, 3, 4, 5};
2020-04-26 17:19:07 +04:00
int main()
{
printf("I'm a C++ program, and I'm running in user space. How about a big, Hello World\n");
printf("My array is at 0x%p\n", myarray);
2020-04-26 05:35:32 +04:00
printf("I'm going to start crunching some numbers, so gimme a minute.\n");
for (int i = 0;i < SIZE;i++) {
myarray[i] = another_array[i % 5];
2020-04-26 05:35:32 +04:00
}
for (int i = 0;i < 100000000;i++) {
myarray[i % SIZE] += 12.34;
2020-04-26 05:35:32 +04:00
}
2020-05-23 00:29:44 +04:00
printf("Ok, I'm done crunching. Wanna see myarray[0]? It's %lf\n", myarray[0]);
return 0;
}