Ubuntu下的wxWidgets编程(学生信息管理写入文件,文件格式是.txt)

wxWidgets和Codeblocks的编译安装,GUI程序开发平台的搭建具体步骤如下:
(1)基本编译环境安装
安装编译工具(gcc之类)sudo apt-get install build-essential 
安装X11sudo apt-get install libx11-dev
安装GTK需要的东西sudo apt-get install?gnome-core-devel
(2)下载wxWidgets源码包并解压缩到 #{wxdir}
(3)创建基于gtk和x11的编译目录${wx}
mkdir ${wx}/buildgtk
mkdir ${wx}/buildx11
(4)编译wxgtk
cd ${wx}/buildgtk
sudo ${wxdir}/configure –with-gtk
sudo make
sudo make install
sudo ldconfig
(5)编译wxx11
cd ${wx}/buildxll
sudo ${wxdir}/configure -–with-x11
sudo make
sudo make install
sudo ldconfig
(6)此时wxGTK与wxX11就都编译并且安装完成了,以后编译程序的时候只需要调用不用的类库即可。
(7)wxconfig --help

1.#include <wx/string.h>

#include <wx/utils.h>
#include <wx/datetime.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
  wxPrintf(wxT("开发平台描述\n"));
  wxPrintf(wxGetOsDescription());
  wxPrintf(wxT("the amount of free memory:\n"));
  long mem = wxGetFreeMemory().ToLong();
  wxPrintf(wxT("Memory: %ld\n"), mem);
  wxPrintf("主机名\n");
  wxPuts(wxGetUserName());
  wxPuts(wxGetFullHostName());
  wxDateTime now = wxDateTime::Now();
  wxString date1 = now.Format();
  wxString date2 = now.Format(wxT("%X"));
  wxString date3 = now.Format(wxT("%x"));
  wxPuts(date1);
  wxPuts(date2);
  wxPuts(date3);
return 0;
}
2.#include <wx/file.h>
#include<wx/string.h> 
#include <wx/textfile.h>
int main() 

wxFile file1;
file1.Create(wxT("stu.txt"), true);
wxString str1,str2;
wxPrintf("输入学生信息:\n");
str1="Mary  0001";
str2="Mike  0002";
file1.Write(str1);
file1.Write(str2);
wxTextFile file(wxT("stu.txt"));   
file.Open(); 
wxPrintf(wxT("行数: %d\n"), file.GetLineCount());
wxPrintf(wxT("第一行: %s\n"), file.GetFirstLine().c_str());
wxPrintf(wxT("最后一: %s\n"), file.GetLastLine().c_str());
wxPuts(wxT("-------------------------------------")); 
wxString s; 
for ( s = file.GetFirstLine(); !file.Eof(); s = file.GetNextLine() ) 

wxPuts(s); 
wxPrintf("\n");

file.Close();
return 0; 
}





转载于:https://www.cnblogs.com/zhangaihua/p/3718077.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值