English 中文(简体)
因此,我计划在执行后不生产胎儿。
原标题:why is my program not outputting info after executing it
  • 时间:2012-05-11 00:15:05
  •  标签:
  • c
  • file-io

目前,我正着手在C实施一个 log木方案,并根据数人的建议,即决定用植被和扫描器来取代红can,但不要像以前那样回到原木档案的最后一条线,否则,方案只会产生一个空白线,然后离开,我对C(几周前开始自学),因此,我可能只是对一些 d错误视而不见,但如果有人能够帮助我这样做,我会非常感激!

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE
void main(int argc, char *argv[], char *envp[])
{
  FILE *fd;
  char *name;
  name = getenv("MCEXEC_PLAYERNAME");
  char *filename;
  filename = malloc(sizeof "/home/minecraft/freedonia/playerdata/deathlog-.txt" - 1 +     strlen(name) + 1);
  if (!filename) exit(EXIT_FAILURE);
  sprintf(filename,"/home/minecraft/freedonia/playerdata/deathlog-%s.txt",name);
  char *buff;
  buff = malloc(1024);
  char *finbuff;
  finbuff = malloc(1024);
  if ((fd = fopen(filename, "r")) != NULL)
  {
    fseek(fd, 0, SEEK_SET);

    while(!feof(fd))
  {
      memset(buff, 0x00, 1024);
      memset(finbuff, 0x00, 1024);
     // fscanf(fd, "%[^
]
", buff);
      fgets(buff, 1024, fd);
      sscanf(buff, "%[^
]
", finbuff);
   }
    printf("%s
", finbuff);
  }
  else
  printf( "fail" );
}

而对于行之有效的版本来说,这完全只是部分评论,而只是部分评论,还有没有将fin列入方案。

   while(!feof(fd))
    {
      memset(buff, 0x00, 1024);
      fscanf(fd, "%[^
]
", buff);
    }
最佳回答

如果乌想要遵守现行法典,那么一片pl子就检查了这条线。

• 午餐,0x00,1024;

我认为,这里存在一些问题,如果能够用u来界定“buff”为静态分配,而不是动态地尝试(char buff[256] ={0})。

页: 1

如果乌可以选择,最后一条线:

int main(){
const char *file = "in";
FILE *in = fopen(file, "r");
if (in != NULL){
int bytes = 0;
int nl = 0;
while(fseek(in, --bytes, SEEK_END) == 0){
if (fgetc(in) ==  
  && ++nl > 2){
break;
}
}
char line[ARG_MAX];
fgets(line, sizeof line, in);
fputs(line, stdout);
fclose(in);
}
return 0;
} 

希望这将有助于。

问题回答

暂无回答




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签