C/C++ :: To Delete Words (The) From Stream

Dec 14, 2014

I need to use getchar and putchar. The task is simple to say but not that easy to implement as it may seem. I end up with:

char c = 0, c_ = 0, c__ = 0;
while ((c = getchar()) != '.') {
if (c == 't') {
c__ = c;
c = getchar();

[Code] ....

If the word "the" is followed with another one, the last isn't eliminated. I enter "thethe" and get "the", what is not right.

View 1 Replies


ADVERTISEMENT

C++ :: Delete Words From A String?

Feb 3, 2015

"Type a function that take in a string containing numbers and others characters and print on stdout all the numbers contained into the string, where for number is mean every maximal numerical sequence, of numbers not separed by spaces. Numbers printed on exit must be separated by commas. For example, if i put in the function the string "paje27hg78 2k f562" my function must print:

27, 78, 2, 562 "

So i started my code like so: (I WANT TO NOTICE THAT WE HAVE ONLY USED IOSTREAM AND FSTREAM LIBRARY FOR NOW, SO DON'T USE OTHERS LIBRARY ELSE MY TEACHER WON'T CORRECT MY HOMEWORK!)

#include <iostream>
#include <fstream>
using namespace std;

[Code].....

View 18 Replies View Related

C/C++ :: Delete From Sentence All Words With Character Count Which Is Equal To Pair Number

Nov 20, 2014

I have an assigment to make program which deletes from sentence all words with character count which is equal to pair number , for example - [ I like C ] and the result of this program should be [I C] because the word like contains 4 characters which is pair and it should be removed.

So I started writing my program and I am stuck at this block of code -

#include <stdio.h>
#include <stdlib.h>
main () {
char text[100], blank[100];
int c=0,d=0,i,j;
gets(text);

[Code] ....

To explain what is happening - I go through all string and search for first ' ' space symbol and check its value. If it is pair then my program prints that it is not pair[because last character before space had not pair number of characters], but the hardest part comes in when i have two not pair words , because space takes one character and now when i check if i%2 == 1 the answer is false [0] for the second word .

View 2 Replies View Related

Visual C++ :: File Stream Change Its Address During Writing Text Contents To The Stream

Apr 29, 2013

I wrote a program to write text contents to file stream through fputs, the file stream address was changed in the middle of writing text content to the stream (11% text content have been put into the file stream), that cause the file stream pointer can be evaluated problem and raise exception on stream validation code in fputs library function, my question is what things could go wrong to make file stream pointer changed its address to something else or a NULL pointer if the file stream have not been flushed and closed.

View 5 Replies View Related

C++ :: Count Number Of Words And Lines Then Print All Words

Dec 20, 2013

I have written below program to count number of words and lines and print the all the words.

#include <iostream>
using namespace std;
#include<fstream>
#include<string.h>
int main() {
ofstream outfile;

[Code] .....

Its compiling fine but when executed its displaying I infinite times...

View 3 Replies View Related

C++ :: How To Pick One Of Words Randomly From Text Instead Of Using All Words In It

May 19, 2013

I was reading this earlier [URL] ..... and I was trying to figure out how to pick one of the words randomly from my text instead of using all the words in it.

View 4 Replies View Related

C :: List - Why Delete Function Doesn't Delete

Dec 9, 2014

I have to manage a Clinic. I need to delete a booking (for example, if John said he's coming on March 22nd at 15:30 but then he say he's not going to come, I have to delete that booking so another person can use it).

idSearched: the id of the person that is not going to come. I have a lot of specialties and each one has a list. So I ask for the speciality to delete the node (the node contains John's booking). If I don't find it, I return (-1). searchSpecByID return a pointer to the list where the speciality is. So head will point to the first node of the list. In nodeToDelete I have the node I want to delete.

The program detects OK when is the first in the list and when not, but it doesn't delete the node.

Code:

typedef struct bookingList{
tSpecialty specialty;
struct nodo* intro;
} tList;

[Code].....

View 7 Replies View Related

C++ :: File Stream Loop

Dec 4, 2013

Why does my loop loops 3 times when i have only 2 line of data in my file? From the cout << s.size , when i run it will show 1,2,3.

Information in txt file
Code:
local john 10/2/1990
international tom 2/5/2000 output Code: local john 10/2/1990
international tom 2/5/2000
international tom 2/5/2000 Code: ifstream in(filename);

[Code] ....

View 4 Replies View Related

C++ :: Displaying Image From Stream

Feb 24, 2013

I'm trying to display an image from a stream data. But there is no image when getting image::from stream.

It's my source code:

Code:
IStream* pstream = NULL;
if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pstream))) {
ULONG lreal = 0;
pstream->Write(chIncomingDataBuffer, iEnd, &lreal );

[Code]...

There is no image from data.

View 5 Replies View Related

C++ :: Copying One File To Another - I/O Stream

Mar 4, 2013

I'm having some trouble with copying one I/O stream into another. I've put the first one into an array but I cannot get my second prompt to copy the .txt file the first prompt sees and outputs to the console. When I try and grab the info from the .txt file my first prompt sees I only see blank space in my .txt file.

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <fstream>
using std::ifstream;
using std::ofstream;

[Code] .....

View 1 Replies View Related

C++ :: Stream Iterators And Buffers?

Feb 6, 2013

Do stream iterators, such as std::istreambuf_iterator<char>, read a chunk of bytes internally, or do they read the stream one byte at a time?

Because I am thinking to write a BufferedFile class which uses an std::vector<char>.

View 3 Replies View Related

C++ ::  reading Stream Value From A File?

Oct 13, 2013

#include<fstream.h>
#include<conio.h>
#include<string>
class CLS {
public : string name;

[code]....

I have used the above code to write the class instanc to a file "Text.txt"...But it seems that "f.write((char*)&c, sizeof(CLS));" is not working properly with string. The data can easily be written using stream object!

#include<fstream.h>
#include<conio.h>
#include<string>
class CLS {
public : string name;

[code]....

When I tried to read the data on the file...., it gave an error "Thread stopped...violation.."

View 7 Replies View Related

C# :: Possible To Send Audio Over Mic Stream?

Mar 10, 2014

I'd like to be able to output sound over skype as if it were coming from my headset, how would I go about this?

View 1 Replies View Related

C++ :: File Stream And String Extraction?

Apr 7, 2014

I am currently trying to read in a file that takes in the input in the following form.

Code:
HANK>25 BOB>31 AL>54
BILL>41 ABE>63 JEFF>50

I have tried the following solution:

Code:
#include<ifstream>
#include<iostream>
using namespace std;
struct node
{
string name;
int age;
);
int main ()
{

[code]....

The problem is a.name, it's extracting the entire string before the space character causing p.age to contain "BOB" and so on. I've tried using p.get(p.name, sizeof(p.name), '-') with '-' as the delimiter and p.getline() using a character array instead of a string. How would it be possible to only copy the string into a.name before the '>' character?

View 1 Replies View Related

C++ :: Redirecting A File Stream To Stdout

Sep 20, 2013

Let us assume I have a program that takes the name of the output file from the command line. Now let us assume that a decided not to give any output file location but wanted my program to to print my strings/ints ... directly to stdout. how would one do this using file streams? Using file pointers and c that is pretty straight forward but how would i achieve this in c++.

View 12 Replies View Related

C++ :: Function That Brings In A Stream Object

Sep 23, 2014

I'm supposed to add two new functions to an existing class that I've written early on: readData(ifstream&)and writeData(ofstream&).

The parameters of the program are:
-Create three employee objects as shown,
-Create an ofstream object and open a file. Choose any name for the file that you want. Do not ask the user for the file name. Pass just the file name as the parameter (no path) so that your program assumes the file to be in the same folder as your executable file.
-Send messages to each of the three Employee objects to write themselves out to the file.
-Close the file.
...

If I get writeData(ofstream&) function bit to work! for brevity I've cut all the functions of the class that arent necessary. Here's what I have so far:

Employee.h
#pragma once
#include<string>
using namespace std;

[Code] ....

So I've tried a bunch of different ways to get my objects into the ofstream object to write them to the file, but I'm supposed to use the two new functions somehow...but I'm way lost.

View 5 Replies View Related

C++ :: How To Add Array Elements To String Stream

Oct 17, 2013

This is my code:

#include <iostream>
#include <string>
#include <istream>
#include <sstream>
using namespace std;
int main() {
string groups[3] = {};

[Code] ....

It outputs jibberish. I can do what I need to do but I would need to declare more variables and write more cout's, isn't there a way to add these elements to a stringstream or streambuffer? My goal is to write this program and make it as comprehensive as possible but also with very few lines.

View 1 Replies View Related

C++ :: Stream Buffer To Base64 String

Oct 2, 2013

I have problem with this code:

#include <windows.h>
#include <stdio.h>
#include <gdiplus.h>
#include "ScreenCap.h"
#include <wchar.h>
#include "base64.h"
#include <sstream>

using namespace Gdiplus;
int GetEncoderClsid(WCHAR *format, CLSID *pClsid) {

[Code] ....

This function return me a long series of Y ended with other chars but not the base64 string.

I think the problem is std::string encodedstring = base64_encode(buffer, dwBufferSize); but I can't figure out the problem.

The base64 function is: [URL] ....

View 2 Replies View Related

C++ :: File Input Stream Not Loading?

May 9, 2014

#include <cstdlib>
#include <stdio.h>
#include <string>

[Code]....

I'm trying to load a file input stream to load all the character content into a variable (say from a .java file for example), but for some reason whenever I type in the name of the file I want to stream I get the report: RUN FAILED (exit value 1, total time 2s)

View 7 Replies View Related

C++ :: Overloading Stream Extraction Operator?

Oct 1, 2013

I wrote a class that can display fractions ex. 1/4 and I cannot figure out how to get >> to process 1/4 and separate them into variables numerator and denominator.

my program just constantly creates RationalNumber Objects when it reaches cin >> A .

my overloaded stream extraction function:

istream& operator >> (istream& in, const RationalNumber& rn)
{
char L;

[Code].....

View 1 Replies View Related

C++ :: Optional Parameter In String Stream

Sep 2, 2013

I'm reading in a data set using an ifstream, then fetching line by line to a stringstream:

std::ifstream sfile(filename);
std::string test;
std::getline(sfile, test);
std::stringstream sline(test);

(I'm not sure why I used an intermediate string; it's pretty much legacy-code at this point, which I just reuse every time. Still works, so why change it!)

The problem is I'm using two types of data sets now, and the difference is one (optional). Most data files just have an arbitrarily large number if the second must be ignored, but others have nothing.

In the normal case, I'd simply use sline >> d >> L; to extract the parameter values. However, I'm not sure how this line will behave if the second parameter is omitted. Will it read nonsense? How do I check whether or not the parameter was set or not?

View 7 Replies View Related

C++ :: BAC Calculator - String Stream Search

May 14, 2013

I am working on a project which is a fairly simply BAC calculator. I am attempting to grab data from a text file, which contains state abbreviation, maximum BAC before aggravated, and minimum license suspension. The text file looks like

#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <stdio.h>
#include <ctype.h>
#include <iomanip>
#include <algorithm>
#include <cstdlib>
#include <sstream>
using namespace std;

float MALE_RATE = 0.68, FEMALE_RATE = 0.55, LEGAL_LIMIT = 0.08;
//percent of body weight which holds alcohol

[Code] ....

The code I am struggling with is the getline and stringstream which is near the bottom.

The output I am getting is

The maximum BAC before aggrevated DUI in AL is .15
The minimum penalty in AL is 90 day suspension of license

I get that for every state I type. I know it is reading the first line, but something in my code does not allow it to read the other lines

View 1 Replies View Related

C++ :: Different Random Number Stream For Different Functions?

Mar 4, 2014

I am wondering is there a way to make function A uses random number stream say starting from srand(1) and function B uses random number stream say starting from srand(2) in the same program.

View 3 Replies View Related

C# :: Unable To Read Beyond The End Of The Stream Error

Feb 13, 2014

Once it gets to string name = fileWrite.ReadString(); in write file it throws this exception about unable to read beyond the end of the stream.

static void Main(string[] args)
{
WriteFile();
ReadFile();

[Code]....

View 4 Replies View Related

C/C++ :: Passing A Stream Object By Reference?

May 5, 2014

I need to create a function in my program to open an input file and another function to open an output file and I need to use the files in other functions so Im trying to pass the stream object by reference but then i need a condition that tells the compiler not to reopen the file because then it will delete everything and make me input the file names again. Heres the two functions.

void InputFileOpen(ifstream &inFile) {
string file_name;
if(!inFile.is_open()){
cout<< "Enter the input file name: ";
cin>> file_name;
inFile.open(file_name, ios::in);

[code]....

View 4 Replies View Related

C# :: Stream Video From LAN Server Onto Client PC?

Oct 9, 2014

I have loads of movies on DVD and they are all on my media server, but the media server doesn't actually allow streaming to be done, the movies are just stored in a folder on the desktop.

My goal would be able to host all my movies on my LAN server, then build an application to run on a windows based PC at home, not over the Internet just over LAN. For example, say the server I have at home had all the movies in a folder on the desktop, then when I start the client on another PC or laptop in my house, I could view all the movies, choose which one and then stream it to that client PC. I am using C#.NET WPF visual studio.

Maybe I could use something like VLC player to play the movies but I would want to build an client application to view the movies and search for them on the server where the movies are stored. Also I know there are other media streaming programs out there but I want to develop my own one for my uses.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved