i can not cin
Code:
cin >> "Text added to input stream here " >> variable >> endl ;
ok i get it you can only have
why does cin not allow you to add text <constant string> to the input stream like you can in other langs ?
second cin question
Code:
/* testcin.cpp*/
#include "testcin.h"
#include <iostream>
using namespace std;
// char made global so <in theory> it can be use with the for function inside the header.h
// <sarcasmmeow> it only works in theory </sarcasmmeow>
char a;
char b;
int main() {
cout << "input text a " ;
cin >> a ;
cout << endl ;
cout << "input text b " ;
cin >> b ;
cout << endl ;
dtext( &a , &b ) ;
// also if i use cout << dtext (&a , &b) << endl ; i get errors
} // end main
Code:
/* testcin.h */
#ifndef TESTCIN_H
#define TESTCIN_H
#include <iostream>
using namespace std;
void dtext ( char *pt , char *ytc ) {
cout << " *pt ==> " << pt << endl ;
cout << " *ytc ==> " << ytc << endl ;
// also as soon as i add a for loop here i loose the vlaues of both variables inside the for loop
for( int i = 0 ; i < 1000 ; i++ ) {
cout << " *pt ==> " << pt << endl ;
cout << " *ytc ==> " << ytc << endl ;
cout << endl ;
} // end for loop
// after for loop and after loss of value of the variables return answer is not correct
// see above cout note
} //end dtext
#endif
output
input text a
g
input text b
v
*pt ==>
gv
*ytc ==>
v
...
note the two letters. it was only supposed to print one. another error. why ? mehow ?