如何从文件中删除一些字符? [英] how to remove some character from a file?
本文介绍了如何从文件中删除一些字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何删除文件中的一些字符?我有一个文件,我想从中删除一些字符,我想将一些字符交换到anot
她和我应该在不使用临时字符串的情况下完成它。通常如何更改内容的文件?
解决方案
参见下面的示例并根据您的要求对其进行更改: -
这只是想法你怎么做
#include < iostream >
#include < cstdio >
#include < fstream >
#include < string > ;
int main()
{
ifstream file( vowels.txt);
char cstr [ 80 ];
while (!file.eof())
{
file.getline(cstr, 80 );
for ( int i = < span class =code-digit> 0 ; i< cstr.length(); i ++)
{
if (cstr [i] == ' a' || cstr [i] == ' e' || cstr [i] == ' i' || cstr [i] == ' o ' || cstr [i] = ' u')
{
cstr [i] = ' ';
}
else
{
text [i] = putchar(toUpper(text [i]));
}
}
}
system( pause);
return 0 ;
}
请描述要删除的字符类型?
我在VB中创建了一个应用程序。特定和私人使用的网络。
但是,如果您能描述您的问题,那么只有会员可以帮助您。 :)
how i can delete some char in a file?i have a file and i want to remove some char from it and i want to swap some char to another and i should done it without using a temp string.in generally how to change in content 's file?
解决方案
See below example and made changes in that as per your requirement:-
this is just idea how you can do that
#include<iostream> #include<cstdio> #include<fstream> #include<string> int main () { ifstream file("vowels.txt"); char cstr[80]; while (!file.eof()) { file.getline(cstr,80); for(int i = 0; i < cstr.length(); i++) { if(cstr[i] == 'a' || cstr[i] == 'e' || cstr[i] == 'i' || cstr[i] == 'o' || cstr[i] ='u') { cstr[i] = ''; } else { text[i]= putchar(toUpper(text[i])); } } } system("pause"); return 0; }
Please describe what type of characters you want to remove?
I have created an application in VB.Net for specific and private use.
but, if you can describe your question then only members can help you. :)
这篇关于如何从文件中删除一些字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文