S
S
Seth262014-07-20 22:07:12
Programming
Seth26, 2014-07-20 22:07:12

How to make a text entry?

#include
using namespace std;
int main()
{
string s;
cin>>s;
system("PAUSE");
return 0;
}
It is necessary to make it so that with each change in s, the value is written to the textbox, erasing the previous value

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
rukbrook, 2014-07-20
@Seth26

it is possible like this:

#include <iostream>
#include <fstream>
#include <string>

using std::cin;
using std::string;


int main(){
  setlocale(LC_ALL,"Russian");
  
  string str;
  while(cin >> str)//While Ctrl-Z (Ctrl-D *nix)
  { 
    std::ofstream exp("text.txt");
    exp << str << std::endl;
  }
}

F
falsebyte, 2014-07-20
@falsebyte

To do this, you need to "reset" the old value.
Approximately as follows:

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

int main()
{
int i;
for (i=0;i<3;i++)
    {
    char str[10]="";
    printf("first print %s\n",str);
    scanf("%s",str);
    printf("second print %s\n",str);
    }
return 0;
}

when executed, this will be:
./test
first print
123
second print 123
first print
456
second print 456
first print
789
second print 789

P
Pavel, 2014-07-20
@VoRez

www.c-cpp.ru/books/reading-i-zapis-v-tekstovye-fayly

E
Evgeniy Samoilenko, 2014-07-20
@samoilenkoevgeniy

bit.ly/1rC1IVy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question