I want to extract polynomial coefficient out of a string recieved by input, for example if i enter 4x^3+2x^4+3 , the resulting out put be : 2 , 4 , 0 , 0 , 3
User enters sentence "The Smiths have two daughters, three sons, two cats and one dog." (The numbers may change depending on what the user chooses to enter. He told us the range would be from zero to nine.) and we have to convert the written numbers within the sentence into actual decimal numbers and print out the new sentence. Ex. The Smiths have 2 daughters, 3 sons...etc.
I have written the following bit of code which reads the string and finds all the "written numbers" but I am not sure how to proceed from there. I am stuck on how to print out the new sentence with the converted numbers as my professor mentioned something about creating the new string using dynamic memory allocation.
Code: #include <stdio.h>#include <string.h> int main () { char A[100]; int length = 0; int i;
We have an assignment to produce code to gather a string of input from the user in which they are entering a date. We then have to extract parts of that string to make substrings, and display different formats for the date(I will add my code in here so you can see what I have done). It took me a long while plucking away at this to understand this part. You will see that at the end of my code I have opened a file months.txt. We were provided with a file which states months corresponding to dates. I.e. 01January 02February 03March 04April, and so on until December. Exactly how I have typed it is how it is in the file.
I understand how to open and extract what is in the file as a string. I have extracted this as a string called myMonth (as you can see in the code as well) NOW,
I am supposed to have the program search for the month in the file, matching that to the month the user has input earlier, and then use the number infront of that month. I understand the basics of using find(), and making substrings. But how on earth do you get the computer to correlate what the user has input for a month, to finding that in the file, and then using the correct number.
Here is the code I have done so far:
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { string myDate; // Date input from user; string myMonth; // Input from months.txt
Create a simple data file like the example shown below containing the 4 dates below plus 10 or more additional dates. The file should include 1 date per line and each date should have the form MonthNumber-DayOfTheMonth-Last2DigitsOfTheYear with no extra spaces. All dates should be in this century. No error checking for invalid dates is necessary.
My Output displays like
February -19,1991
How do I get my program to ignore the dash between the dates?
#include <fstream> #include <iostream> #include <string> #include <cmath> using namespace std; int main(){ const int M = 13;
I got as far as getting a web page into an IHTMLDocument2 but I don't know what to do from there, all the examples I found are C# or .NET or something else I don't understand.
Any simple example in C++ of getting all the links from an IHTMLDocument2 ?
I was able to do this:
Code: IHTMLElementCollection* collection; hResult=document->get_links(&collection); long nLinks; collection->get_length(&nLinks); // returns correct number collection->Release();
How do I loop through the collection and extract the actual links ? Also, if they come out as BSTR do I simple treat them as WCHAR* ? If I can do that I can figure out the rest myself.
I am trying to automatically extract all time stamps in a pdf file. These are typically in a line like:
when="2010-07-30T15:20:30+04:00"
For this I was thinking of using CStdioFile and the ReadString function. Somehow this doesn't work. My example code is below. Is this because pdf is not a true text file, because strings read can be longer than some max,...? Any quick way of reading the file and extracting the desired text between the brackets?
Code: CStdioFile InputFile; if (InputFile.Open(FileName,CFile::modeRead)) {
So this may be against the rules, not sure, grey area probably? However I just bought the PC game Oil Rush, and was having a look at how the assets are packed. As with most games the textures, scripts, sounds and audio are all free to access.
However the game data such as maps, models and other, are packed into UNG files, i.e a custom encrypted file format, which probably is also compressed. So I googled for an unpacker/extracter and found one which also comes with the C source. You can download here. [URL] ....
So I am trying to figure out how these authors work out this file format, from the source we have,
If I have a number 117, represented in binary as : 01110101 and I wanted to grab the top nibble. What would be the decimal value I would be extracting?
Would it be 0111 or 0101 decimal values 112 or 5 or is my understanding completely wrong?
I am writing a program to play rock paper scissors, and I am trying to get a vector to store the result of a given round of play, and output it as a declaration as to who won. I can't figure out how to store the values in the vector properly, and how to use the vector as an argument to output the result of play.
so i have a loop that will run x number of times and each time it will produce a prize which is a certain sum of money. I need to a way to sum all the money earned. I am thinking there should be a way to extract the prize one for each time the loop runs but i am not sure how to do that.
In this string there are some numbers with a dash between them, for example, "5-10". I need to read these numbers in and then increment them. So "5-10" becomes "6-11", "6-11" becomes "7-12", etc.
So far I have:
Code: char temp[350]; //350 chars is plenty enough
// Copy the first characters BEFORE the numbers into a new char array. The next characters are the numbers. strncpy(temp, *objectData, 39); The next steps are: - Extract the two numbers from the C string (determining if the number is 0,2 or 3 digits long) and write them into two ints. I'm stuck here.
- Increment the ints
- Write the ints into the array with a dash inbetween.
I have a code for subtract of two char arrays(size of each is 50).but i want to write this program with string and i should be consider that size of each string may be not equals.for example we have s1=4777 and s2=55.and we should be subtract them. This is my code.
char* sub(char x[50],char y[50]) { int i,j,temp=0; char z[50]={'0'}; for(i=0;i<50;i++)
I have a upcoming C++ exam. I would like to write a program to convert INDIVIDUAL digits into words.
E.g 678 = six seven eight[/size][/b]
I have the following code:
//Program to print individual digits in words #include<iostream> using namespace std; int main() { int num; cout << "Enter a number between 0 and 9999: ";
I have written a C++ program I have multiple of CSV file used as input, which I open one at a time and close it after extracting data to a output file which is the only file.
I run getline(inFile,line); outFile << line << endl;
I run this code, and only part of it is goes to the output file I got, also have spacing randomly to specific file and inconsistent
But when I slower the code, like system("Pause") in the loop, I can get extract what I want perfectly....
Is my program running to fast, why getline would be skipping part of what things I want?
I know strings are essentially just arrays of characters, so what would be the easiest way to take each individual digit and put it into a separate space in an array?
I am trying to read user input for recipe ingredients which must include a ingredient name, and may include a quantity and a unit. Example: Stone ground flour 2 cups or Sugar 1 Tbsp or Milk. The problem I am having is that the string gets cut off after a space when multiple words are used for the ingredient name.
This program gets input from a file and output to the screen and to a file. The difficulty I am having is summing the number I retrieve from the file for the individual numbers of sightings.
#include <fstream> // enables us to read and write files #include <iostream> // for cin and cout #include <cstdlib> #include <string> // enables us to hold strings of characters #include <cctype> using namespace std;
My program reads a string of characters. Prints all occurrences of letters and numbers, sorted in alphabetical and numerical order. Letters will be converted to uppercase.Other characters are filtered out, while number of white spaces are counted.
the problem is it crushes when i run the program
Here is my code
#include <iostream> const int SIZE = 100; using namespace std; int main() { char *pStr, str[SIZE] = "", newStr[SIZE] = "", ch; int count = 0, i = 0, j;