fork download
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <mysql.h>
  4. #include <string>
  5. #include <iostream>
  6. void main()
  7. {
  8. char InputPath[] = "D:\\tttrrr\\";
  9. //放要讀取檔案的資料夾路徑到InputPath字串裡
  10. char szDir[MAX_PATH];
  11. char dir[MAX_PATH];
  12. WIN32_FIND_DATA FileData;
  13. HANDLE hList;
  14. //------------------------------------------------------
  15. //資料庫變數
  16. char user[] = "root";
  17. char pswd[] = "";
  18. char host[] = "localhost";
  19. char table[] = "user";
  20. unsigned int port = 3306;
  21. MYSQL myCont;
  22. MYSQL_RES *result;
  23. MYSQL_ROW sql_row;
  24. int res;
  25. //----------------------------------------------------------
  26. mysql_init(&myCont);
  27. sprintf_s(szDir, "%s\\*", InputPath);
  28. if ((hList = FindFirstFile(szDir, &FileData)) == INVALID_HANDLE_VALUE)
  29. printf("No files be found.\n\n");
  30. else {
  31. while (1) {
  32. if (!FindNextFile(hList, &FileData)) {
  33. if (GetLastError() == ERROR_NO_MORE_FILES)
  34. break;
  35. }
  36. sprintf_s(dir, "%s", FileData.cFileName);
  37. if (strlen(dir) > 3){
  38. if (mysql_real_connect(&myCont, host, user, pswd, table, port, NULL, 0)) //連接資料庫
  39. {
  40. mysql_query(&myCont, "SET NAMES BIG5");
  41. mysql_query(&myCont, "insert into ccc values (NULL, '%s');",dir);
  42. }
  43. printf("%s\n", dir);
  44. }
  45. }
  46. }
  47. FindClose(hList);
  48. system("pause");
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:21: fatal error: windows.h: No such file or directory
 #include <windows.h>
                     ^
compilation terminated.
stdout
Standard output is empty