我一直在尝试学习 C,但我一直坚持包含库。我需要使用 strcpy(),但该方法包含在 iostream 库中,但每当我尝试包含该库时,程序都会出错。我试过使用 "iostream", "iostream.h", , ,但它要么给我一个 "can't find iostream.h" 错误,要么程序超过 100 个错误并且只是崩溃。即使我的代码是空的,我仍然会得到同样的结果。这是代码:
#include "iostream"
int main(void)
{
}
是的,就这么多已经让它崩溃了。这是我遇到的部分错误(永远无法将它们全部粘贴在这里):
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(37): error C2061: syntax error : identifier 'abs'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(37): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(39): error C2061: syntax error : identifier 'acos'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(39): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(39): error C2061: syntax error : identifier 'asin'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(39): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2061: syntax error : identifier 'atan'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2061: syntax error : identifier 'atan2'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2061: syntax error : identifier 'ceil'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(40): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(41): error C2061: syntax error : identifier 'cos'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(41): fatal error C1003: error count exceeds 100; stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
所以是的,它甚至超过了 100 个错误,并且程序停止计数。我不明白为什么,我只是包括一个普通图书馆。有没有等价的 strcpy()?我主要想这样使用它(练习):
#include "stdafx.h"
#include "stdlib.h"
#include "stdio.h"
#include "conio.h"
#include "iostream"
int main(void)
{
struct person
{
int id;
char name[50];
int age;
};
struct person p1;
p1.id = 5595;
strcpy(p1.name, "Myname");
p1.age = 18;
printf("%d%s%d", p1.id, p1.name, p1.age);
}