a program that saves strings

i want to make a program that can get strings from user and save it. for this purpose i want to use getline(); built-in function for getting and saving a string but i have no idea about how i delimit the string like if i want to delimit a string with getline(a,b,#s); when user write #s it saves the string. if i shall use getline(a,b,#s); the program will give error because i am not using a character to delimit a program. please give me suggestions for this program.
thanks!
Last edited on
To use getline() to take all typed in text, use:
getline( std::cin, input, '\n' );

std::cin - console input
input - string
'\n' - end of line (ENTER pressed)
#include<stdio.h>
#include<conio.h>
int main () {
char st[200];
int i = 0;
printf("Enter your string: ");
for( i = 0 ; i < 200 ; i++ ){
st[i] = getche();
if(i != 0 && st[i-1] == '#' && st[i] == 's'){
st[i-1] = ' ';
st[i] = ' ';
printf("\nSAVED\n");
getche();
break;
}
}
if(i == 199){
printf("\nLIMIT REACHED\n");
getche();
}
return 0;
}
Topic archived. No new replies allowed.