Click here to Skip to main content
15,920,217 members

Comments by Member 13527256 (Top 20 by date)

Member 13527256 24-Jan-18 10:31am View    
I used files for this task, and everything works perfectly.
Member 13527256 24-Jan-18 10:30am View    
I finally managed to find an answer to this question myself:
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
FILE *f = fopen("input.txt", "r");
char a;
vector <char> v;
while (f != NULL && fscanf(f, "%c", &a) != EOF)
v.push_back(a);
fclose(f);
//
f = fopen("output.txt", "w");
fprintf(f, "%u", v.size());
return 0;
}
Member 13527256 19-Jan-18 10:08am View    
For example:
User inputs:
Hello, //enter
world!.
My program has to output 13.
But I`ve no idea, how should I make it stop waiting for input after '!'.
Member 13527256 19-Jan-18 9:48am View    
Deleted
My problem - is to input text - some strings. There can be any text given (look at the example) - some sentences, article from newspaper, short tale, etc. But the problem is that there are '\n' symbols at the end of each string, and I have absolutely no idea how to input all that thing in one string - neither cin nor scanf inputs it. In my code I think problem is in endless while operator, but I don`t have to know how to change that.
I know strlen function, that`s not the problem.
Member 13527256 19-Jan-18 9:47am View    
My problem - is to input text - some strings. There can be any text given (look at the example) - some sentences, article from newspaper, short tale, etc. But the problem is that there are '\n' symbols at the end of each string, and I have absolutely no idea how to input all that thing in one string - neither cin nor scanf inputs it. In my code I think problem is in endless while operator, but I don`t have to know how to change that.
I know strlen function, that`s not the problem.