bool MCSVReader::Load(const char* fname) { // 파일 전체를 읽는다 // m_pBuffer = ReadFile(fname); // 라인수를 센 후 각 오프셋을 구한다 // m_nLine = CountLine(m_pBuffer, NULL); m_pOffset = new int[m_nLine]; CountLine(m_pBuffer, m_pOffset); return true; }
static void output_prefix(FILE * fp) { if (symbol_prefix == NULL) { symbol_prefix = "yy"; } else { define_prefixed(fp, "yyparse"); define_prefixed(fp, "yylex"); define_prefixed(fp, "yyerror"); define_prefixed(fp, "yychar"); define_prefixed(fp, "yyval"); define_prefixed(fp, "yylval"); define_prefixed(fp, "yydebug"); define_prefixed(fp, "yynerrs"); define_prefixed(fp, "yyerrflag"); define_prefixed(fp, "yylhs"); define_prefixed(fp, "yylen"); define_prefixed(fp, "yydefred"); define_prefixed(fp, "yydgoto"); define_prefixed(fp, "yysindex"); define_prefixed(fp, "yyrindex"); define_prefixed(fp, "yygindex"); define_prefixed(fp, "yytable"); define_prefixed(fp, "yycheck"); define_prefixed(fp, "yyname"); define_prefixed(fp, "yyrule"); } if (CountLine(fp)) ++outline; fprintf(fp, "#define YYPREFIX \"%s\"\n", symbol_prefix); }
static void ObfuscateStat(toSQLParse::statement &stat, QString &ret) { if (ret.length() > 0 && stat.String.length() > 0 && toIsIdent(ret.at(ret.length() - 1)) && toIsIdent(stat.String.at(0))) { if (CountLine(ret) < 60) ret += QString::fromLatin1(" "); else ret += QString::fromLatin1("\n"); } ret += stat.String; if (!stat.Comment.isEmpty()) { ret += stat.Comment; ret += QString::fromLatin1("\n"); } for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin(); i != stat.subTokens().end(); i++) { ObfuscateStat(*i, ret); } }
static void output_YYINT_typedef (FILE * fp) { /* generate the type used to index the various parser tables */ if (CountLine (fp)) ++outline; fprintf (fp, "typedef %s YYINT;\n", CONCAT1 ("", YYINT)); }
void RobotInitForm::LinePathPlan(){ SendCmdTimer = new QTimer(this); SendCmdTimer->setInterval(SEND_POINT_STEP); pose test_pos; pose end_pos; test_pos.position.x = -0.736397445202; test_pos.position.y = -0.0129018928856; test_pos.position.z = -0.0753068029881; test_pos.orientation.w = 0.999771595001; test_pos.orientation.x = -0.000220606132643; test_pos.orientation.y = -0.0169492401183; test_pos.orientation.z = 0.0130159296095; end_pos.position.x = -0.430622845888; end_pos.position.y = -0.00417962437496; end_pos.position.z = 0.790055513382; slov_size = CountLine(test_pos.position, end_pos.position, test_pos.orientation, 10, 1.0, arm_init_joint_state); if(slov_size == -1){ printf("slove error!\n"); return; } // step 3 申请空间存放解 slov_line_ary = (double*)malloc(sizeof(double)*ARM_DOF*slov_size); CountLineToBuffer(test_pos.position, end_pos.position, test_pos.orientation, 10, 1.0, arm_init_joint_state, slov_line_ary); connect(SendCmdTimer,SIGNAL(timeout()),this,SLOT(SendPathCmd())); slov_count = 0; // SendCmdTimer->start(); SendCmdTimer->start(); }
int main(void) { char fileName[MAXLEN] = "data/input.dat"; FILE *fd = NULL; int nbLines; int i = 0; char **lines; fd = fopen(fileName, "r"); nbLines = CountLine(fd); printf("%d lines\n", nbLines); lines = (char **)malloc((nbLines + 1) * sizeof(char *)); for (i = 0; i < nbLines; i++) { lines[i] = (char *)malloc(sizeof(char) * MAXLEN); } fseek(fd, 0, SEEK_SET); for (i = 0; i < nbLines; i++) { /* char buf[MAXLEN] = ""; */ if(fgets(lines[i], MAXLEN - 1, fd) == NULL){ fprintf(stderr, "error: exit.\n"); exit(EXIT_FAILURE); } } fclose(fd); return EXIT_SUCCESS; }
static void output_prefix(FILE * fp) { if (symbol_prefix == NULL) { symbol_prefix = "yy"; } else { define_prefixed(fp, "yyparse"); define_prefixed(fp, "yylex"); define_prefixed(fp, "yyerror"); define_prefixed(fp, "yychar"); define_prefixed(fp, "yyval"); define_prefixed(fp, "yylval"); define_prefixed(fp, "yydebug"); define_prefixed(fp, "yynerrs"); define_prefixed(fp, "yyerrflag"); define_prefixed(fp, "yylhs"); define_prefixed(fp, "yylen"); define_prefixed(fp, "yydefred"); #if defined(YYBTYACC) define_prefixed(fp, "yystos"); #endif define_prefixed(fp, "yydgoto"); define_prefixed(fp, "yysindex"); define_prefixed(fp, "yyrindex"); define_prefixed(fp, "yygindex"); define_prefixed(fp, "yytable"); define_prefixed(fp, "yycheck"); define_prefixed(fp, "yyname"); define_prefixed(fp, "yyrule"); #if defined(YYBTYACC) if (locations) { define_prefixed(fp, "yyloc"); define_prefixed(fp, "yylloc"); } putc_code(fp, '\n'); putl_code(fp, "#if YYBTYACC\n"); define_prefixed(fp, "yycindex"); define_prefixed(fp, "yyctable"); putc_code(fp, '\n'); putl_code(fp, "#endif /* YYBTYACC */\n"); putc_code(fp, '\n'); #endif } if (CountLine(fp)) ++outline; fprintf(fp, "#define YYPREFIX \"%s\"\n", symbol_prefix); }
int main() { FILE *f = fopen( "onegin.txt", "r" ); assert(f); fseek(f,0,SEEK_END); long const length = ftell(f); char* text = (char*) calloc ( length + 1, sizeof ( *text ) ); assert(text); fseek(f,0,SEEK_SET); //Без этой строчки работает, но неправильно. С ней что то делает, но если в самом начале main поставить printf он его не выводит. fread ( text, sizeof(*text), length, f ); fclose ( f ); f = NULL; text[length] = '\0'; long massLine = CountLine(text, length); char** line = (char**) calloc(massLine, sizeof( *line ) ); assert(line); PartingLines(text, line, massLine); // char** sortline = (char**) calloc(massLine, sizeof( *sortline ) ); // assert(sortline); SortingLines(line, massLine); FILE* sort_file = fopen("sortonegin.txt", "w"); for (long i = 0; i < massLine; i++) { fprintf(outputfile,"%s\n",line[i]); } fclose(outputfile); outputfile = NULL; free(text); text = NULL; free(line); line = NULL; return 0; }
static void define_prefixed (FILE * fp, const char * name) { int bump_line = CountLine (fp); if (bump_line) ++outline; fprintf (fp, "\n"); if (bump_line) ++outline; fprintf (fp, "#ifndef %s\n", name); if (bump_line) ++outline; fprintf (fp, "#define %-10s %s%s\n", name, symbol_prefix, name + 2); if (bump_line) ++outline; fprintf (fp, "#endif /* %s */\n", name); }