Skip to content

Instantly share code, notes, and snippets.

@mahata
Created September 25, 2011 18:58
Show Gist options
  • Save mahata/1240963 to your computer and use it in GitHub Desktop.
Save mahata/1240963 to your computer and use it in GitHub Desktop.
C++ Primer 8.1
#include <iostream>
const int max_str_len = 255;
void silly_function(char * print_string, int flag = 0);
int main()
{
using namespace std;
char sample_string[max_str_len] = "Hello, world!";
silly_function(sample_string);
silly_function(sample_string);
silly_function(sample_string);
silly_function(sample_string, 1);
return 0;
}
void silly_function(char * print_string, int flag)
{
using namespace std;
static int times = 0;
times++;
cout << "-- start output @ silly_function --" << endl;
if (0 == flag) {
cout << print_string << endl;
return;
}
for (int i = 0; i < times; i++) {
cout << print_string << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment