C++ :: Read String Of Characters And Write With Punctuation Removed
Oct 13, 2014
Write a program that reads a string of characters including punctuation and writes what was read but with the punctuation removed.
This is how i did it:
string x("#punctuation!?=");
cout << x << endl;
for(unsigned i = 0; i < x.size(); ++i) {
if(ispunct(x[i]))
x[i] = ' ';
cout << x << endl;
I am just not sure if thats how they want you to do it because it doesn't remove the punctuations it just replaces them with a space.
View 3 Replies
Oct 12, 2014
How to read some characters from file, I know we can move a pointer to some position using seekg() & seekp() function, get current position of the pointer through tellg() & tellp() functions. By moving the pointer to appropriate position using seekg(), we can read the whole line using getline() function. But is there any function which read certain characters from the current position of the pointer and write certain characters from current position of the pointer.
View 1 Replies
View Related
Oct 12, 2014
How to read some characters from file, I know we can move a pointer to some position using seekg() & seekp() function, get current position of the pointer through tellg() & tellp() functions. By moving the pointer to appropriate position using seekg(), we can read the whole line using getline() function. But is there any function which read certain characters from the current position of the pointer and write certain characters from current position of the pointer.
View 3 Replies
View Related
Dec 11, 2014
I have it searching through the entire string letter by letter, looking for spaces, punctuation, etc... yet it still is continuing on with the space.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <stdio.h>
#include <cctype>
#include <algorithm>
[Code] ....
Output:
if(str_word == " ")
//or
if(str_word == ' ')
It does nothing to change it. I am completely baffled.
View 4 Replies
View Related
Mar 13, 2013
how to read characters from user and construct a sting and then extract part of it using substring?
View 2 Replies
View Related
Mar 20, 2014
so my question is i want to print characters,no string just an array of characters,i do this but it s not working,maybe i have to put the '' at the end?
Code:
int main() {
int i;
char ch[5];
for(i = 0; i < 5; i++) {
scanf("%c",&ch[i]);
[Code]...
View 6 Replies
View Related
Jul 6, 2014
Im supposed to find the common characters between two string characters, assuming that the user wont input duplicate letters like ddog. When I run my code I get an output of a question mark upside down. Here is my code with comments on what each part is supposed to do
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char str1[20], str2[20],remp = '