从输入文件中删除所有空格并将其存储到新文件中 [英] Removing all white spaces from an input file and storing into a newfile

查看:188
本文介绍了从输入文件中删除所有空格并将其存储到新文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用c或c ++编写一个程序,在删除所有空格(包括单个空格,多个空格,制表符空格和换行符)后,读取输入文件并将其全部内容复制到输出文件中.
我尝试过的事情:

无法开始








/

Write a program in c or c++ that reads an input file and copies its entire contents into an output file after removing all white spaces which includes single space, multiple spaces, tab space and new lines.

What I have tried:

couldnt get started








/

推荐答案

您必须学习一些编码,但是我会给您一些提示.使用 strchr 函数,您会在字符串中出现一个字符.有了这些信息,您就可以创建一个新字符串,其左,右部分没有要消除的字符.如果您可以使用库,则可以使用替换和一个空字符(").
查找并了解 ASCII字符的含义,以找到制表符和换行符.

祝您功课顺利.
You must learn some coding, but I will give you some tips. With the function strchr you get the occurance of a char in a string. With that information you can make a new string with left and right part without the char you want to eliminate. If you can use libraries than you can use replace with an empty char ("").
Look and learn the meaning of ASCII-characters to find the tabs and new lines.

Good luck with your homework.


这篇关于从输入文件中删除所有空格并将其存储到新文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆