Skip to content

Commit f0cc663

Browse files
committed
Update default C++ program to demonstrate container files
1 parent c784037 commit f0cc663

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
CC=g++
22
all:
3-
$(CC) -Wall *.cpp
3+
$(CC) -Wall *.cpp
4+
5+
.PHONY: clean
6+
7+
clean:
8+
rm -f *.o*

main.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
#include <iostream>
2+
#include <fstream>
23

34
using std::cout;
5+
using std::fstream;
46

57
int main()
68
{
7-
cout << "C++ program";
9+
const char* LOGFILE = "logs/data.txt";
10+
fstream output;
11+
output.open(LOGFILE, std::ios::out);
12+
13+
if( output.is_open() )
14+
{
15+
cout << LOGFILE << " opened.\n";
16+
output << "Program has been run! in the container!\n";
17+
output.close();
18+
}
19+
cout << "C++ program complete.\n";
820

921
return 0;
1022
}

test_runner.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

3-
bash --version
4-
echo $?
3+
make clean && make
4+
./a.out

0 commit comments

Comments
 (0)