Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Please help. How to solve this problem?!

+1 vote
asked Mar 23, 2018 by anonymous 1 flag
Write a function in C++ to read a text file “SPACE.TXT” . Using this file create another file “ OUT.TXT”  by  replacing more than one space by single space.  

Example:

If the file “SPACE .TXT” contains the  following

I      like    ice cream.

The function should create another file OUT.TXT with the text

 I like ice cream.

2 Answers

0 votes
answered Mar 23, 2018 by Shane Such (840 points)
so where are you having problems? i don't have much experience with using inputs from a file but i'm a second pair of eyes and most likely it's bracketing.
0 votes
answered Apr 1, 2018 by sai ram Adapa (190 points)
there is a program called converting into upper case better you check it out.both are simmilar you'll get out the correct answer
#include<stdio.h>
#include<stdlib.h>
int main()
{
    FILE*fp1,*fp2;
    char ch;
    fp1=fopen("source.txt","r");
    if(fp1==NULL)
    {
        puts("file does not exist");
        exit(1);
    }
    fp2=fopen("target.txt","w");
    if(fp2==NULL)
    {
        puts("file does not exist");
        fclose(fp1);
        exit(1);
    }
    while((ch=fgetc(fp1))!=EOF)
    {
        ch=toupper(ch);
        fputc(ch,fp2);
    }
    printf("\n file sucessfully copied");
    return(0);
}0
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...