Skip to content

Commit 7ba645b

Browse files
authored
Merge pull request fbsamples#12 from fbsamples/carljparker/use-std-string-20180727
Use std::string and cout instead of * char and printf
2 parents 63bebfd + 9aeb8c6 commit 7ba645b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

hello-buck-cxx/hello-buck.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include "stdio.h"
1+
#include <iostream>
22
#include "hello-string.h"
33

44
int main () {
55

66
hello_string * hello = new hello_string();
77

8-
printf( "Hello, %s\n", hello -> get_string() );
8+
std::cout << "Hello, " << hello -> get_string() << std::endl;
99

1010
return( 0 );
1111

hello-buck-cxx/hello-string.cxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
//
55
// HELLOSTRING is defined in .buckconfig
66
//
7-
const char * hello_string::HELLO = HELLOSTRING;
7+
const std::string hello_string::HELLO = HELLOSTRING;
88

99
hello_string::hello_string() {};
1010

11-
const char * hello_string::get_string() {
11+
const std::string hello_string::get_string() {
1212

1313
return( HELLO );
1414

hello-buck-cxx/hello-string.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
#include <string>
2+
13
class hello_string {
24

35
private:
4-
static const char * HELLO;
6+
static const std::string HELLO;
57

68
public:
79
hello_string();
810

9-
const char * get_string();
11+
const std::string get_string();
1012

1113
};
1214

0 commit comments

Comments
 (0)