fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. char buf[1000];
  8. int i = 123;
  9.  
  10. // TODO: error checking, buffer checking
  11. char* ptr = buf;
  12. ptr += sprintf(ptr, "Text format, i=%d", i);
  13. strcpy(ptr, " and five (5) percent signs: %%%%%");
  14.  
  15. cout << buf << endl;
  16. }
Success #stdin #stdout 0s 4292KB
stdin
Standard input is empty
stdout
Text format, i=123 and five (5) percent signs: %%%%%