2009-08-02 57 views
2

我正在学习C++,但我只开发控制台应用程序,因为图形C++开发是如此困难,那么我想知道,如果我可以开发控制台像Palm OS应用程序,我是什么想要的是,编译此代码为Palm OS为例:开发控制台就像应用程序的Palm OS

// ClientFille.cpp 
// Cria um arquivo sequencial. 

#include <iostream> 
using std::cerr; 
using std::cin; 
using std::cout; 
using std::endl; 
using std::ios; 

#include <fstream> // Fluxo de arquivos 
using std::ofstream; // Gera a saída do fluxo do arquivo 

#include <cstdlib> 
using std::exit; // Sai do protótipo de funcão 

int main() 
{ 
    // Construtor ofstream abre arquivo 
    ofstream outClientFile("Clients.dat", ios::out); 

    // Fecha o programa se não conseguir criar o arquivo 
    if (!outClientFile) // Operador ! sobrecarregado 
    { 
     cerr << "File could not be opened" << endl; 
     exit(1); 
    } // Fim do if 

    cout << "Enter the account, name, and balance." << endl 
     << "Enter end-of-file to end the input.\n? "; 

    int account; 
    char name[ 30 ]; 
    double balance; 

    // Lê conta, nome e saldo a partir de cin, então coloca no arquivo 
    while (cin >> account >> name >> balance) 
    { 
     outClientFile << account << ' ' << name << ' ' << balance << endl; 
     cout << "? "; 
    } // Fim do while 

    return 0; // Destruitor ofstream fecha o arquivo 
} // Fim de main 

谢谢!

+3

一分钟开发自己的操作系统,下一个他自己的编译器。现在在一个Palm上编写C++应用程序!我不得不承认,与纳丹在一起时刻都没有沉闷。 – 2009-08-02 21:30:33

回答

1

Palm OS上唯一的内置stdin/stdout接口是秘密的“网络控制台”。我在旧博客条目http://palmos.combee.net/blog/HiddenIOConsole.html上写了这篇文章。然而,这并没有C++绑定,因此您需要创建自己的流类来调用这些函数,并且您需要的旧版SDK已经被ACCESS当前的网站所遗忘。您可以在Palm OS的CodeWarrior旧版本中找到它。

2

I/O的命令行界面方法在围绕大多数用户交互的触摸/点按屏幕设计的设备上效率不高 - 因此尽管您可能会找到某种方式来执行控制台操作,类型I/O,它不会是一个理想的用户体验。

更何况,大多数Palm设备(和其他PDA)没有完整的102+键键盘 - 所以输入像EOF这样的东西不会是微不足道的。

+0

这是仅适用于我或Palm OS库的应用程序。 – 2009-08-02 21:27:08

相关问题