私は最近学校でC/C++プログラミングを始めました(2か月前)ので、私は何をしているのか分かりません。致命的なエラーLNK1120:未解決の外部が2つ
私のコードから、私はこれらのエラーメッセージを受け取った:
エラーLNK2019:(?MyRand @@ YANNN @ Z)未解決の外部シンボル "ダブル__cdecl MyRand(ダブル、ダブル)" エラー_main機能で参照しLNK2019 :未解決の外部シンボル(love_code @@ YAHXZ?) 致命的なエラーLNK1120 _main機能で参照「(ボイド)int型__cdecl love_code」:2つの未解決の外部
私はこのサイト上の鉱山に類似の質問を見てきましたが、どれもの提供されたソリューションは私のために働いた。このエラーを修正するにはどうすればよいですか?
元のコードを提供し、誰かが知りたいと思われる出力が表示される画像。
マイコード:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
double length (double x1, double y1, double z1, double x2, double y2, double z2);
double squares (double x);
double MyRand (double a, double b);
int love_code();
int main()
{
char name[20], parent[15];
strcpy_s(name, "Susan McLeod");
strcpy_s(parent, "Bernice McLeod");
int i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13;
i2 = name[0], i3 = name[1], i4 = name[2], i5 = name[3], i12 = name[4], i13 = name[5];
i6 =parent[0], i7=parent[1], i8=parent[2], i9=parent[3], i10=parent[4], i11=parent[5];
cout << "The ASCII code of [" << name << "] are " <<'['<< i2 <<']'<<'['<< i3 <<']'<<'['<< i4 <<']'<<'['<< i5 <<']'<<'['<< i12 <<']'<<'['<< i13 <<']'<< endl;
cout << "The ASCII code of [" << parent << "] are " <<'['<< i6 <<']'<<'['<< i7 <<']'<<'['<< i8 <<']'<<'[' << i9 <<']'<<'['<< i10 <<']'<<'['<< i11 <<']'<< endl;
int j, love, txtcode, shift, len;
FILE *f1, *f2, *f3;
char txt [5000];
love = love_code();
cout << "The love code is [" << love << ']' << endl;
srand (love);
fopen_s(&f1, "letter.txt", "r");
fopen_s(&f2, "hw_04_code.txt", "w");
fopen_s(&f3, "hw_03_code.txt", "w");
if (f1 == NULL) printf ("Cannot open file - letter.txt\n");
if (f2 == NULL) printf ("Cannot open file - hw_04_code.txt\n");
if (f3 == NULL) printf ("Cannot open file - hw_03_code.txt\n");
j = 0;
while (fscanf_s (f1, "%c", &txt [j]) !=EOF)
{
shift = (int) (MyRand (0, 6));
txtcode = txt [j] << shift;
fprintf (f3, "%10d\n", txt [j]);
//fprintf (f2, "%10d, %10d\n", txtcode, shift)
fprintf (f2, "%10d\n", txtcode);
j++;
}
txt [j] = '\0';
len = strlen (txt);
printf ("The total number of characters are %d\n", len);
fclose (f1);
fclose (f2);
fclose (f3);
return (0);
}
//return random number between a and b
double MyRand (double a, double b);
{
return ((b - a + 1) * rand()/(double) RAND_MAX + a);
}
Double MyRand(double a、double b); < - セミコロンの運命> – user4581301
['fscanf_s'](https://msdn.microsoft.com/ja)の使用-us/library/6ybhk9kc.aspx)が間違っています。フォーマットタイプ '%c'と'%s'では、** size **引数とターゲットポインタが必要です。コンパイラの警告を有効にしてください。 * "より安全な関数(接尾辞_sが付いている)と他のバージョンとの主な違いは、c、C、s、Sの各文字のサイズがより安全な関数では、変数の直後の引数 "* –
' love_code() 'の格言のみが存在します。これの実装を書いてください。 – saygins