user-0 提问: 用c语言写了个解析文件并写入到数据库，求大师指导！

回复:
user: user-1
content: 迟来的幸福！

user: user-0
content: 突然回来结个贴。不好意思，问题解决了。

user: user-1
content: 先将demo目录下插入数据的例子编译链接调试通过，再将其中操作数据库相关部分照搬到自己的代码中。

user: user-0
content: 引用 13 楼 zhao4zhong1 的回复:参考oracle中的例子代码demo\*.*  参考了demo例子，还是出现那个问题，在引入sql头文件时， #include <sqlca.h> 和 EXEC SQL include "sqlca.h" 和 EXEC SQL include sqlca 这三者有什么区别吗？ 始终报 DzxxHB.c: In function 'main': DzxxHB.c:30: error: 'EXEC' undeclared (first use in this function) DzxxHB.c:30: error: (Each undeclared identifier is reported only once DzxxHB.c:30: error: for each function it appears in.) DzxxHB.c:30: error: expected ';' before 'SQL' DzxxHB.c:32:50: warning: multi-character character constant DzxxHB.c: In function 'parseFileToSQL': DzxxHB.c:111: error: 'EXEC' undeclared (first use in this function) DzxxHB.c:111: error: expected ';' before 'SQL' 这个错，崩溃了。

user: user-1
content: 参考oracle中的例子代码demo\*.*

user: user-0
content: 引用 11 楼 zhao4zhong1 的回复:你代码中：  	// 连接数据库并插入数据 EXEC SQL CONNECT GAPS/GAPS; 需要进一步编写函数完成对应功能。 参考oracle中的例子代码demo\*.*  fprintf(sql,"insert into yw_dsdf_dzxx_hb values('%s','%s','%s','%s','%s','%d','%s','%d')",yhbh,gyh,yhlsh,yhbh_1,jfrq,sfje,sfqd,isznbsf);  EXEC SQL INSERT INTO yw_dsdf_dzxx_hb values(sql); 这个算是吗？写了个insert 函数

user: user-1
content: 你代码中：  	// 连接数据库并插入数据 EXEC SQL CONNECT GAPS/GAPS; 需要进一步编写函数完成对应功能。 参考oracle中的例子代码demo\*.*

user: user-0
content: 对于头文件的引用，不晓得下面这些正确吗？ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <dirent.h> #include <time.h> #include <sqlca.h>

user: user-0
content: [quote=引用 7 楼 zhao4zhong1 的回复:] [quote=引用 4 楼 xiaolubian 的回复:] [quote=引用 3 楼 zhao4zhong1 的回复:] [code=c]#include <stdio.h> #include <windows.h> char *getYesterday() {     FILETIME ft;     SYSTEMTIME st;     static char yesterday[9];  我新手，感谢指导，自己也在不断编译调试中，现在的问题如下： DzxxHB.c:31:50: warning: multi-character character constant DzxxHB.c: In function 'parseFileToSQL': DzxxHB.c:68: error: 'EXEC' undeclared (first use in this function) DzxxHB.c:68: error: (Each undeclared identifier is reported only once DzxxHB.c:68: error: for each function it appears in.) DzxxHB.c:68: error: expected ';' before 'SQL' DzxxHB.c:74: warning: passing argument 1 of 'strstr' from incompatible pointer type /usr/include/string.h:342: note: expected 'const char *' but argument is of type 'struct FILE *' DzxxHB.c:75: error: 'BUFFSIZE' undeclared (first use in this function) DzxxHB.c:75: error: 'file' undeclared (first use in this function) DzxxHB.c:76: error: incompatible types when assigning to type 'char[1024]' from type 'int' DzxxHB.c:77: error: incompatible types when assigning to type 'char[1024]' from type 'int' DzxxHB.c:80: error: incompatible types when assigning to type 'char[4]' from type 'char *' DzxxHB.c:81: error: incompatible types when assigning to type 'char[8]' from type 'char *' DzxxHB.c:82: error: incompatible types when assigning to type 'char[6]' from type 'char *' DzxxHB.c:83: error: incompatible types when assigning to type 'char[4]' from type 'char *' DzxxHB.c:84: error: incompatible types when assigning to type 'char[8]' from type 'char *' DzxxHB.c:85: error: incompatible types when assigning to type 'double[20]' from type 'char *' DzxxHB.c:86: error: incompatible types when assigning to type 'char[3]' from type 'char *' DzxxHB.c:87: error: incompatible types when assigning to type 'int[1]' from type 'char *' DzxxHB.c:89: warning: passing argument 1 of 'fprintf' from incompatible pointer type /usr/include/stdio.h:355: note: expected 'struct FILE * __restrict__' but argument is of type 'char *' DzxxHB.c:92: error: expected ';' before 'SQL' DzxxHB.c:97: error: incompatible types when assigning to type 'char[1024]' from type 'int' DzxxHB.c:98: error: incompatible types when assigning to type 'char[1024]' from type 'int' DzxxHB.c:101: error: incompatible types when assigning to type 'char[4]' from type 'char *' DzxxHB.c:103: error: incompatible types when assigning to type 'char[8]' from type 'char *' DzxxHB.c:104: error: incompatible types when assigning to type 'char[1024]' from type 'char *' DzxxHB.c:111: error: incompatible types when assigning to type 'char[4]' from type 'char *' DzxxHB.c:112: error: incompatible types when assigning to type 'double[20]' from type 'char *' DzxxHB.c:113: error: incompatible types when assigning to type 'char[3]' from type 'char *' DzxxHB.c:114: error: incompatible types when assigning to type 'int[1]' from type 'char *' DzxxHB.c:115: warning: passing argument 1 of 'fprintf' from incompatible pointer type /usr/include/stdio.h:355: note: expected 'struct FILE * __restrict__' but argument is of type 'char *' DzxxHB.c:118: error: expected ';' before 'SQL'

user: user-1
content: 引用 5 楼 xiaolubian 的回复:在请教下哈  GetSystemTimeAsFileTime(&ft);     *(__int64 *)&ft-=864000000000i64;     FileTimeToSystemTime(&ft,&st); 这个是个什么意思？ GetSystemTimeAsFileTime(&ft);//取当前系统时间放在ft中 *(__int64 *)&ft-=864000000000i64;//将ft减去86400秒 FileTimeToSystemTime(&ft,&st);//将ft转为st

user: user-1
content: 引用 4 楼 xiaolubian 的回复:[quote=引用 3 楼 zhao4zhong1 的回复:] #include <stdio.h> #include <windows.h> char *getYesterday() {     FILETIME ft;     SYSTEMTIME st;     static char yesterday[9];      GetSystemTimeAsFileTime(&ft);     *(__int64 *)&ft-=864000000000i64;     FileTimeToSystemTime(&ft,&st);     sprintf(yesterday,"%4d%02d%02d",st.wYear, st.wMonth, st.wDay);     return (char *)yesterday; } int main() {     printf("%s\n",getYesterday());     return 0; }   如果是在Linux下就不能用了吧，我看这边引了windows.h [/quote] 说 “跨平台一定比不跨平台好” 就和说 “双性恋一定比异性恋好” 一样！

user: user-1
content: 引用 4 楼 xiaolubian 的回复:[quote=引用 3 楼 zhao4zhong1 的回复:] #include <stdio.h> #include <windows.h> char *getYesterday() {     FILETIME ft;     SYSTEMTIME st;     static char yesterday[9];      GetSystemTimeAsFileTime(&ft);     *(__int64 *)&ft-=864000000000i64;     FileTimeToSystemTime(&ft,&st);     sprintf(yesterday,"%4d%02d%02d",st.wYear, st.wMonth, st.wDay);     return (char *)yesterday; } int main() {     printf("%s\n",getYesterday());     return 0; }   如果是在Linux下就不能用了吧，我看这边引了windows.h [/quote] 你一楼给的代码里面不是也用了SYSTEMTIME吗？linux下有SYSTEMTIME？

user: user-0
content: 在请教下哈  GetSystemTimeAsFileTime(&ft);     *(__int64 *)&ft-=864000000000i64;     FileTimeToSystemTime(&ft,&st); 这个是个什么意思？

user: user-0
content: 引用 3 楼 zhao4zhong1 的回复:#include <stdio.h> #include <windows.h> char *getYesterday() {     FILETIME ft;     SYSTEMTIME st;     static char yesterday[9];      GetSystemTimeAsFileTime(&ft);     *(__int64 *)&ft-=864000000000i64;     FileTimeToSystemTime(&ft,&st);     sprintf(yesterday,"%4d%02d%02d",st.wYear, st.wMonth, st.wDay);     return (char *)yesterday; } int main() {     printf("%s\n",getYesterday());     return 0; }   如果是在Linux下就不能用了吧，我看这边引了windows.h

user: user-1
content: #include <stdio.h> #include <windows.h> char *getYesterday() {     FILETIME ft;     SYSTEMTIME st;     static char yesterday[9];      GetSystemTimeAsFileTime(&ft);     *(__int64 *)&ft-=864000000000i64;     FileTimeToSystemTime(&ft,&st);     sprintf(yesterday,"%4d%02d%02d",st.wYear, st.wMonth, st.wDay);     return (char *)yesterday; } int main() {     printf("%s\n",getYesterday());     return 0; }

user: user-0
content: 引用 1 楼 zhao4zhong1 的回复:获取前一天不能简单地将日期减一。 那要怎么做？

user: user-1
content: 获取前一天不能简单地将日期减一。