Skip to content

Instantly share code, notes, and snippets.

@kobake
Created August 26, 2018 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobake/72d8f07b6f49ec92969dc0dd8111a3bc to your computer and use it in GitHub Desktop.
Save kobake/72d8f07b6f49ec92969dc0dd8111a3bc to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
// For specify int
template <int N>
class Buffer {
public:
Buffer() {
m_buf[0] = 0;
}
char* Pointer() {
return m_buf;
}
private:
char m_buf[N];
};
int main()
{
Buffer<100> buf;
strcpy(buf.Pointer(), "Hello");
printf("%hs\n", buf.Pointer());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment