我正在测试它的使用情况,fprintf()但它无法正常工作.当我第一次编写代码时,我忘记添加\n内部fprintf()并且它有效.但是,当我\n在"测试1 2"的开头添加时,它停止工作.
#include <stdio.h>
#include <stdlib.h>
int main ()
{
FILE* f = fopen("test.txt", "r+");
if( f == NULL) return 0;
char str[4][10];
for(int a = 0; a <= 3; ++a)
{
fscanf(f, " %[^\t\n]s", str[a]);
printf("%s\n", str[a]);
}
fprintf(f, "\ntest 1 2\n");
fclose(f);
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的test.txt包含(而不是\t和\n我按下选项卡,并在文件中输入,但我不能在这里进行管理)
ab\tcd\te \n fg
程序没有输入它想要输入的if语句.例如,当sentence1是oguzhan而句子2是第一个字符的bugrahan时,它应该输入第一个if语句结束替换应该是4,但它不是.
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cmath>
using namespace std;
int main() {
char sentence1[50];
char sentence2[50];
int m, n, k, l;
int i, j, substitution;
cout << "Enter the first word:" << endl;
cin >> sentence1;
cout << "Enter the second word:" << endl;
cin >> sentence2;
m = strlen(sentence1);
n = strlen(sentence2);
int cost[m + 1][n + 1];
cost[0][0] = 0;
for (i = 1; i < m + 1; i++) {
cost[i][0] = …Run Code Online (Sandbox Code Playgroud)