打印

请生成这样一个文件,方法不限

引用:
原帖由 肯抽C肯抽V 于 2008-6-27 00:51 发表

日语我也不知道
英语叫thread
日语不知道
哦哦哦,知道这个东西,是スレッド,这是日语的外来语,有时候他们还不如把英语直接写那里,我来日本这么久了,看到片假名还是不大带劲,邪门了。

TOP

。。。C,文件操作,字符操作,搞定。不用那么多复杂的东西吧,简单问题简单做。

TOP

引用:
原帖由 be_kicked 于 2008-6-27 10:46 发表
。。。C,文件操作,字符操作,搞定。不用那么多复杂的东西吧,简单问题简单做。
哈哈,复杂以后方法不就多了吗

TOP

通常的方法
public class test{
          public static void main(String args[]) throws IOException{
                  char zimu='a';
                  int i;
                  java.io.FileWriter fileWriter = new java.io.FileWriter("c:\\out.txt");
                  for (i=0;i<26;i++){
                          int aChar = (int)zimu;
                          fileWriter.write(aChar);
                          fileWriter.write("\r\n");
                          zimu+=1;                         
                  }
                  fileWriter.close();       
        }
        }
孤鸿海上来,池潢不敢顾。

TOP

引用:
原帖由 feng1959 于 2008-6-27 11:33 发表
通常的方法
public class test{
          public static void main(String args[]) throws IOException{
                  char zimu='a';
                  int i;
                  java.io.FileWriter fileWriter = new java.io.FileWriter("c:\\out.txt");
           ...
又一个Java高手啊,谢谢回帖。

TOP

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#define LOOPS 26
#define FILENAME "output"
#define RETRYTIME 3

int main(int argc , char **argv)
{
    /*make file and fail check*/
    FILE * fp = fopen(FILENAME , "w+");
    if (NULL == fp) {
        perror("Can't open file!\n");
        exit(0);
    }

    /*make string pointer*/
    int flag = RETRYTIME;   //retry times!
MEM_J:
    char * sp = (char *)malloc(sizeof(char) * LOOPS * 2);
    /*location fail!*/
    if (NULL == sp) {
        free(sp);
        perror("Memory location failured!\n");
        --flag;

        assert(flag != 0);    //time over!
        goto MEM_J;
    }

    /*make string*/
    int loop = LOOPS;
    int i = 0;
    char ch = 'a';
    while (loop) {
        sp[i++] = ch;
        sp[i++] = '\n';
        ++ch;
        --loop;
    }

    /*write string to file*/
    fwrite(sp , sizeof(char) , LOOPS * 2 , fp);

    /*resource return*/
    fclose(fp);
    free(sp);

    return EXIT_SUCCESS;
}

TOP

引用:
原帖由 be_kicked 于 2008-6-27 18:19 发表
#include
#include
#include

#define LOOPS 26
#define FILENAME "output"
#define RETRYTIME 3

int main(int argc , char **argv)
{
    /*make file and fail check*/
    FILE * fp = fopen(FILENAME , "w+" ...
和你们这些小伙子每天一起研究点东西,发点帖子心里特充实。 谢回帖了

TOP

看到go to了
日本人看到go to就不看别的了 好像发现了天大的错误似的

TOP

引用:
原帖由 苏小白 于 2008-6-27 18:43 发表
看到go to了
日本人看到go to就不看别的了 好像发现了天大的错误似的
嗯,我也不喜欢用goto语句,模块小的时候还没什么,大了的时候,goto会让你吐血的。

TOP

想写个重复申请内存,结果好像没什么好办法,只好用了goto,用setjmp好像没必要。
大家有什么好的方法啊?

TOP