我已经坚持了很长时间,由于某种原因我的 C 代码没有编译。它会产生很多 cmath 错误
因为将我的代码和错误放在一起会占用大量空间:
#include <stdlib.h>
#include <stdio.h>
#include <Windows.h>
#include <fstream>
typedef unsigned char* pointer;
void printDbPointers(void);
void show_int(int);
void show_bytes(unsigned char*, int);
void floatingPointRep();
void fahrenheit();
int main()
{
int a = 100;
show_int(a);
floatingPointRep();
fahrenheit();
printDbPointers();
Sleep(100000);
return 0;
}
void printDbPointers(){
char hi[7] = {'t', 'i', 'g', 'e', 'r', '\0'};
char *p, **dp;
p = &(hi[0]);
dp = &p;
printf("%c %c\n", *p, **dp);
printf("%p %p %p\n", p, *dp, hi);
p+=1;
printf("%c, %c\n", *p, **dp);
printf("%p %p %p\n", p, *dp, hi);
*dp+=2;
printf("%c, %c\n", *p, **dp);
printf("%p %p %p\n", p, *dp, hi);
}
void show_int(int x)
{
show_bytes((pointer) &x, sizeof(int));
}
void show_bytes(pointer start, int len)
{
int i;
for(i=0;i<len;i++)
{
// printf("0x%p\t0x%.2x\n", start + i, start[i]);
printf("0x%p\t\n", start + i, start[i]);
printf("\n");
}
}
void floatingPointRep()
{
float f1 = 1.0;
float f2 = 0.0;
int i;
for ( i=0; i<10; i++ ) {
f2 += 1.0/10.0;
}
printf("0x%08x 0x%08x\n", *(int*)&f1, *(int*)&f2);
printf("f1 = %10.8f\n", f1);
printf("f2 = %10.8f\n\n", f2);
f1 = 1E30;
f2 = 1E-30;
}
void fahrenheit()
{
int i;
double arr[3] = {12345678.000, 98765345.333, 456793332.300};
for (i = 0; i < 3; i++)
printf ("%g\n", arr[i]);
}
但是,如果将问题代码放在其他地方违反了 SO 的规则,请告诉我,我会放在这里
73 error C1003: error count exceeds 100; stopping compilation
4 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 28 1
7 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 29 1
11 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 30 1
15 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 31 1
19 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 32 1
23 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 33 1
27 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 34 1
31 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 35 1
34 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 37 1
37 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 38 1
41 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 39 1
45 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 40 1
49 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 41 1
53 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 42 1
57 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 43 1
61 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 44 1
64 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 46 1
66 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 48 1
69 error C2059: syntax error : ';' c:\program files\microsoft visual studio 11.0\vc\include\cmath 49 1
63 error C2061: syntax error : identifier 'abs' c:\program files\microsoft visual studio 11.0\vc\include\cmath 46 1
65 error C2061: syntax error : identifier 'acos' c:\program files\microsoft visual studio 11.0\vc\include\cmath 48 1
3 error C2061: syntax error : identifier 'acosf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 28 1
33 error C2061: syntax error : identifier 'acosl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 37 1
67 error C2061: syntax error : identifier 'asin' c:\program files\microsoft visual studio 11.0\vc\include\cmath 48 1
5 error C2061: syntax error : identifier 'asinf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 28 1
35 error C2061: syntax error : identifier 'asinl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 37 1
68 error C2061: syntax error : identifier 'atan' c:\program files\microsoft visual studio 11.0\vc\include\cmath 49 1
70 error C2061: syntax error : identifier 'atan2' c:\program files\microsoft visual studio 11.0\vc\include\cmath 49 1
8 error C2061: syntax error : identifier 'atan2f' c:\program files\microsoft visual studio 11.0\vc\include\cmath 29 1
38 error C2061: syntax error : identifier 'atan2l' c:\program files\microsoft visual studio 11.0\vc\include\cmath 38 1
6 error C2061: syntax error : identifier 'atanf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 29 1
36 error C2061: syntax error : identifier 'atanl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 38 1
71 error C2061: syntax error : identifier 'ceil' c:\program files\microsoft visual studio 11.0\vc\include\cmath 49 1
9 error C2061: syntax error : identifier 'ceilf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 29 1
39 error C2061: syntax error : identifier 'ceill' c:\program files\microsoft visual studio 11.0\vc\include\cmath 38 1
72 error C2061: syntax error : identifier 'cos' c:\program files\microsoft visual studio 11.0\vc\include\cmath 50 1
10 error C2061: syntax error : identifier 'cosf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 30 1
12 error C2061: syntax error : identifier 'coshf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 30 1
42 error C2061: syntax error : identifier 'coshl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 39 1
40 error C2061: syntax error : identifier 'cosl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 39 1
13 error C2061: syntax error : identifier 'expf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 30 1
43 error C2061: syntax error : identifier 'expl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 39 1
14 error C2061: syntax error : identifier 'fabsf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 31 1
44 error C2061: syntax error : identifier 'fabsl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 40 1
16 error C2061: syntax error : identifier 'floorf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 31 1
46 error C2061: syntax error : identifier 'floorl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 40 1
17 error C2061: syntax error : identifier 'fmodf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 31 1
47 error C2061: syntax error : identifier 'fmodl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 40 1
18 error C2061: syntax error : identifier 'frexpf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 32 1
48 error C2061: syntax error : identifier 'frexpl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 41 1
20 error C2061: syntax error : identifier 'ldexpf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 32 1
50 error C2061: syntax error : identifier 'ldexpl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 41 1
22 error C2061: syntax error : identifier 'log10f' c:\program files\microsoft visual studio 11.0\vc\include\cmath 33 1
52 error C2061: syntax error : identifier 'log10l' c:\program files\microsoft visual studio 11.0\vc\include\cmath 42 1
21 error C2061: syntax error : identifier 'logf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 32 1
51 error C2061: syntax error : identifier 'logl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 41 1
24 error C2061: syntax error : identifier 'modff' c:\program files\microsoft visual studio 11.0\vc\include\cmath 33 1
54 error C2061: syntax error : identifier 'modfl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 42 1
25 error C2061: syntax error : identifier 'powf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 33 1
55 error C2061: syntax error : identifier 'powl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 42 1
26 error C2061: syntax error : identifier 'sinf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 34 1
28 error C2061: syntax error : identifier 'sinhf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 34 1
58 error C2061: syntax error : identifier 'sinhl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 43 1
56 error C2061: syntax error : identifier 'sinl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 43 1
29 error C2061: syntax error : identifier 'sqrtf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 34 1
59 error C2061: syntax error : identifier 'sqrtl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 43 1
30 error C2061: syntax error : identifier 'tanf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 35 1
32 error C2061: syntax error : identifier 'tanhf' c:\program files\microsoft visual studio 11.0\vc\include\cmath 35 1
62 error C2061: syntax error : identifier 'tanhl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 44 1
60 error C2061: syntax error : identifier 'tanl' c:\program files\microsoft visual studio 11.0\vc\include\cmath 44 1