Created
April 14, 2018 03:23
-
-
Save bossxomlut/13be0a3094f7f171efa6e47873f3ce90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| #include<conio.h> | |
| #include <fcntl.h> //_O_U16TEXT | |
| #include <io.h> //_setmode() | |
| #include <string.h> | |
| #include<malloc.h> | |
| #include<wchar.h> | |
| #pragma warning (disable: 4996) | |
| #include <stdlib.h> | |
| struct SinhVien | |
| { | |
| wchar_t MSSV[10]; | |
| wchar_t HoVaTen[30]; | |
| wchar_t Khoa[30]; | |
| int Khoa_s; | |
| wchar_t NgaySinh[11]; | |
| wchar_t AnhCaNhan[30]; | |
| wchar_t MoTa[1000]; | |
| wchar_t SoThich[500]; | |
| wchar_t Email[50]; | |
| }; | |
| /*void xoadauvacuoi(wchar_t *&b) | |
| { | |
| int i=0; | |
| for(int i=1;i<wcslen(b);i++) | |
| { | |
| b[i-1]=b[i]; | |
| } | |
| b[wcslen(b)-2]='\0'; | |
| if(b[wcslen(b)-1]=='\"') | |
| { | |
| b[wcslen(b)-1]='\0'; | |
| } | |
| }*/ | |
| wchar_t** gantungdong(FILE *f,int &n) | |
| { | |
| n=0; | |
| wchar_t **a = (wchar_t**)malloc(1*sizeof(wchar_t*)); | |
| while(!feof(f)) | |
| { | |
| a[n]=(wchar_t*)malloc(1600*sizeof(wchar_t)); | |
| fgetws(a[n],1600,f); | |
| if(!feof(f)) | |
| { | |
| n++; | |
| a=(wchar_t**)realloc(a,(n+1)*sizeof(wchar_t*)); | |
| } | |
| else | |
| break; | |
| } | |
| return a; | |
| } | |
| void ganthongtin(wchar_t *b, wchar_t a[]) | |
| { | |
| for(int i=0;i<wcslen(b)+1;i++) | |
| a[i]=b[i]; | |
| } | |
| SinhVien* laythongtin(wchar_t a[]) | |
| { | |
| int index = 0; | |
| wchar_t **b = (wchar_t **)malloc(8*sizeof(wchar_t)); | |
| wchar_t *p; | |
| p = wcstok(a,L"\",\"" ); | |
| while(p != NULL) | |
| { | |
| b[index] = p; | |
| index++; | |
| p = wcstok(NULL,L"\",\""); | |
| } | |
| SinhVien* sv = (SinhVien*)malloc(sizeof(SinhVien)); | |
| ganthongtin(b[0],sv->MSSV); | |
| //ganthongtin(b[0],(wchar_t*)sv->MSSV); | |
| //wcstombs(sv->MSSV,b[0],10); // chuyển wchar_t -> char nhưng k thành | |
| ganthongtin(b[1],sv->HoVaTen); | |
| ganthongtin(b[2],sv->Khoa); | |
| sv->Khoa_s=_wtoi(b[3]); | |
| ganthongtin(b[4],sv->NgaySinh); | |
| //ganthongtin(b[4],(wchar_t*)sv->NgaySinh); | |
| ganthongtin(b[5],sv->AnhCaNhan); | |
| ganthongtin(b[6],sv->MoTa); | |
| ganthongtin(b[7],sv->SoThich); | |
| ganthongtin(b[8],sv->Email); | |
| return sv; | |
| } | |
| void main() | |
| { //khai báo biến | |
| //khai báo | |
| //-------------------------------- | |
| _setmode(_fileno(stdout), _O_U16TEXT); //needed for output | |
| _setmode(_fileno(stdin), _O_U16TEXT); //needed for input | |
| //---------------- | |
| wchar_t** a; | |
| int n; | |
| FILE* fp=_wfopen(L"tep.csv",L"r,ccs=UTF-8"); // mở tệp | |
| a=gantungdong(fp,n); | |
| SinhVien* A=(SinhVien*)malloc(sizeof(SinhVien)); | |
| int i=1; | |
| //for(int i=0;i<n+1;i++) | |
| //{ | |
| /*A=laythongtin(a[i]); | |
| wprintf(L"%s\n",A->MSSV); | |
| wprintf(L"%ls\n",A->HoVaTen); | |
| wprintf(L"%ls\n",A->Khoa); | |
| wprintf(L"%ld\n",A->Khoa_s); | |
| wprintf(L"%ls\n",A->NgaySinh); | |
| wprintf(L"%ls\n",A->AnhCaNhan); | |
| wprintf(L"%ls\n",A->MoTa); | |
| wprintf(L"%ls\n",A->SoThich); | |
| //}*/ | |
| A=laythongtin(a[0]); | |
| wprintf(L"%s\n",A->MSSV); | |
| wprintf(L"%ls\n",A->HoVaTen); | |
| wprintf(L"%ls\n",A->Khoa); | |
| wprintf(L"%ld\n",A->Khoa_s); | |
| wprintf(L"%ls\n",A->NgaySinh); | |
| wprintf(L"%ls\n",A->AnhCaNhan); | |
| wprintf(L"%ls\n",A->MoTa); | |
| wprintf(L"%ls\n",A->SoThich); | |
| wprintf(L"%ls\n",A->Email); | |
| wchar_t filename[50]; | |
| wcscpy(filename,A->MSSV); | |
| wcscat(filename,L".html"); | |
| FILE* fo=_wfopen(filename,L"wt,ccs=UTF-8"); | |
| fwprintf(fo,L"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"); | |
| fwprintf(fo,L"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"); | |
| fwprintf(fo,L" <head>\n"); | |
| fwprintf(fo,L" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"); | |
| fwprintf(fo,L" <link rel=\"stylesheet\" type=\"text/css\" href=\"personal.css\" />\n"); | |
| fwprintf(fo,L" <title>HCMUS - %ls</title>\n",A->HoVaTen); | |
| fwprintf(fo,L" </head>\n"); | |
| fwprintf(fo,L" <body>\n"); | |
| fwprintf(fo,L" <div class=\"Layout_container\">\n"); | |
| fwprintf(fo,L" <!-- Begin Layout Banner Region -->\n"); | |
| fwprintf(fo,L" <div class=\"Layout_Banner\" >\n"); | |
| fwprintf(fo,L" <div><img id=\"logo\" src=\"Images/abc.jpg\" height=\"105\" /></div>\n"); //logo tự nhiên mở tệp ở trong folder Images cùng vs tệp html | |
| fwprintf(fo,L" <div class=\"Header_Title\">TRƯỜNG ĐẠI HỌC KHOA HỌC TỰ NHIÊN </div>\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" <!-- End Layout Banner Region -->\n"); | |
| fwprintf(fo,L" <!-- Begin Layout MainContents Region -->\n"); | |
| fwprintf(fo,L" <div class=\"Layout_MainContents\">\n"); | |
| fwprintf(fo,L" <!-- Begin Below Banner Region -->\n"); | |
| fwprintf(fo,L" <div class=\"Personal_Main_Information\">\n"); | |
| fwprintf(fo,L" <!-- Begin Thông tin cá nhân ----------------------------------------------------------------------------------------- -->\n"); | |
| fwprintf(fo,L" <div class=\"Personal_Location\">\n"); | |
| fwprintf(fo,L" <img src=\"Images/abc.jpg\" width=\"27\" height=\"33\" />\n"); // có cái gì đó chưa hiểu | |
| fwprintf(fo,L" <span class=\"Personal_FullName\">%ls - %ls</span>\n",A->HoVaTen, A->MSSV); | |
| fwprintf(fo,L" <div class=\"Personal_Department\">%ls</div>\n",A->Khoa); | |
| fwprintf(fo,L" <br />\n"); | |
| fwprintf(fo,L" <div class=\"Personal_Phone\">\n"); | |
| fwprintf(fo,L" Email: %ls\n",A->Email); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" <br />\n"); | |
| fwprintf(fo,L" <br />\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" <!-- End Thông tin cá nhân ----------------------------------------------------------------------------------------- -->\n"); | |
| fwprintf(fo,L" <div class=\"Personal_HinhcanhanKhung\">\n"); | |
| fwprintf(fo,L" <img src=\"Images/%ls\" class=\"Personal_Hinhcanhan\" />\n",A->AnhCaNhan); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" <!-- End Below Banner Region -->\n"); | |
| fwprintf(fo,L" <!-- Begin MainContents Region -->\n"); | |
| fwprintf(fo,L" <div class=\"MainContain\">\n"); | |
| fwprintf(fo,L"\n"); | |
| fwprintf(fo,L" <!-- Begin Top Region -->\n"); | |
| fwprintf(fo,L"\n"); | |
| fwprintf(fo,L" <div class=\"MainContain_Top\">\n"); | |
| fwprintf(fo,L"\n"); | |
| fwprintf(fo,L" <div class=\"InfoGroup\">Thông tin cá nhân</div>\n"); | |
| fwprintf(fo,L" <div>\n"); | |
| fwprintf(fo,L" <ul class=\"TextInList\">\n"); | |
| fwprintf(fo,L" <li>Họ và tên: %ls</li>\n",A->HoVaTen); | |
| fwprintf(fo,L" <li>MSSV: %ls</li>\n",A->MSSV); | |
| fwprintf(fo,L" <li>Sinh viên khoa: %ls</li>\n",A->Khoa); | |
| fwprintf(fo,L" <li>Ngày sinh: %ls</li>\n",A->NgaySinh); | |
| fwprintf(fo,L" <li>Email: %ls</li>\n",A->Email); | |
| fwprintf(fo,L" </ul>\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" <div class=\"InfoGroup\">Sở thích</div>\n"); | |
| fwprintf(fo,L" <div>\n"); | |
| fwprintf(fo,L" <ul class=\"TextInList\">\n"); | |
| fwprintf(fo,L" <li>%ls</li>\n",A->SoThich); | |
| fwprintf(fo,L" </ul>\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" <div class=\"InfoGroup\">Mô tả</div>\n"); | |
| fwprintf(fo,L" <div class=\"Description\">\n"); | |
| fwprintf(fo,L" %ls\n",A->MoTa); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L"\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L"\n"); | |
| fwprintf(fo,L"\n"); | |
| fwprintf(fo,L" <!-- Begin Layout Footer -->\n"); | |
| fwprintf(fo,L" <div class=\"Layout_Footer\">\n"); | |
| fwprintf(fo,L" <div class=\"divCopyright\">\n"); | |
| fwprintf(fo,L" <br />\n"); | |
| fwprintf(fo,L" <img src=\"Images/LogoFooter_gray.jpg\" width=\"34\" height=\"41\" /><br />\n"); | |
| fwprintf(fo,L" <br />\n"); | |
| fwprintf(fo,L" @%d</br>\n",A->Khoa_s); | |
| fwprintf(fo,L" Đồ án giữa kỳ</br>\n"); | |
| fwprintf(fo,L" Kỹ thuật lập trình</br>\n"); | |
| fwprintf(fo,L" TH2018/04</br>\n"); | |
| fwprintf(fo,L" 1712916 - Ngô Tấn Vịnh</br>\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" <!-- End Layout Footer -->\n"); | |
| fwprintf(fo,L" </div>\n"); | |
| fwprintf(fo,L" </body>\n"); | |
| fwprintf(fo,L"</html>\n"); | |
| fclose(fo); | |
| getch(); | |
| free(A); | |
| fclose(fp); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment