cygwin から g++ を使用しています。.cpp ファイルをコンパイルしようとしていますが、エラーが発生しています。
コードは次のとおりです。
#include "randomc.h"
#include <time.h> // Define time()
#include <stdio.h> // Define printf()
#include <cstdlib>
int main(int argc, char *argv[] ) {
int seed = atoi(argv[1]);
int looptotal = atoi(argv[2]);
//initializes rng, I want to use argv[1] to set seed
void CRandomMother::RandomInit (int seed) {
int i;
// loop for the amount of times set by looptotal and return random number
for (i = 0; i < looptotal; i++) {
double s;
s = Random();
printf("\n%f", s)
}
}
return 0;
}
これは、cygwin ターミナルと g++ を使用してコンパイルしようとしたときに発生するエラーです。
Administrator@WIN-19CEL322IRP /cygdrive/c/xampp/xampp/htdocs$ g++ ar.cpp -o prog
ar.cpp: In function `int main(int, char**)':
ar.cpp:13: error: a function-definition is not allowed here before '{' token
ar.cpp:13: error: expected `,' or `;' before '{' token
.cpp ファイルとヘッダー ファイル randomc.h は、私の xampp の場所にあります。これはまったく問題にすべきではないと思いますよね?これをコンパイルして実行する方法を教えてください。ありがとう。