Created
September 25, 2011 18:58
-
-
Save mahata/1240963 to your computer and use it in GitHub Desktop.
C++ Primer 8.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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