how to detect a particular string in a file using C program

前端 未结 3 634
温柔的废话
温柔的废话 2021-01-28 15:40

I have a file and I want to read this file using C program using file operations. Then i want to take parameters from that file. Lets say nalu_type=x. So whenever i detect the s

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 16:27

    If the format is nalu_type = x

     fscanf(fp, "%s", buf);
    if !strcmp(buf, "nalu_type")
    {
       fscanf(fp, "%s", buf);
        if ( ! strcmp(buf, "="))
         fscanf(fp, "%s", buf);
        else
        printf("\n Not a valid format");
    }
    

    Repeat the above if until end of file.

提交回复
热议问题