相关疑难解决方法(0)

如何替换字符串中出现的所有字符?

将所有出现的角色替换为另一个角色的有效方法是什么std::string

c++ algorithm stdstring str-replace

450
推荐指数
7
解决办法
46万
查看次数

使用fopen打开文件,在Windows上给定绝对路径

我正在尝试创建一个计算文件行数的程序,当我尝试将绝对路径传递给fopen函数时,只是告诉我找不到,这是我的代码:

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

using namespace std;

int main(int argc, char *argv[])
{
    int i=0;
    char array[100];

        char caracteres[100];
        FILE *archivo;
        archivo = fopen("C:\Documents and Settings\juegos psps.txt","r");
        if (archivo == NULL){cout<<"Dont Work";}
        while (feof(archivo) == 0)
        {
                fgets(caracteres,100,archivo);
                i++;
                }
                cout << "Number of lines:" << i ;
                return 0;
}
Run Code Online (Sandbox Code Playgroud)

我应该如何将绝对路径传递给我的程序,以便打开文件?

c++ windows fopen file relative-path

13
推荐指数
2
解决办法
5万
查看次数

标签 统计

c++ ×2

algorithm ×1

file ×1

fopen ×1

relative-path ×1

stdstring ×1

str-replace ×1

windows ×1