Skip to content

Instantly share code, notes, and snippets.

@segfo
Last active October 4, 2015 00:17
Show Gist options
  • Save segfo/2fc52be91d35ed41756a to your computer and use it in GitHub Desktop.
Save segfo/2fc52be91d35ed41756a to your computer and use it in GitHub Desktop.
#include <iostream>
#include<string.h>
using namespace std;
int main()
{
// これはあくまでも一例、C++ではString型を使うこと。
// Cの書き方とC++の書き方を混ぜるのはあまり良くない。
int v = 12; // プログラム的に変わる変数v(variable)
char *hoge = new char[v]; // 動的配列の生成
strncpy(hoge,"hello world",11);
cout << hoge << endl;
delete [] hoge;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment