C :: Extracting Second Row From Array?

Mar 1, 2015

I'm having trouble trying to extra the second row from the array:

Code: double data[10][10] = {{0,5,10,15,20,25,30,35,40,45},{0,13,22,37,54,62,64,100,112,126}};

When I do this, it posts the entire array:

Code: int x,y;
for(x=0;x<2;x++)
{
for(y=0;y<10;y++)
{
printf("%.0lf ",data[1][y]);
}
}

View 5 Replies


ADVERTISEMENT

C++ :: Extracting Numbers From A String

Dec 5, 2014

So, I have a string and I need to extract numbers from it. I've tried different things but they are not working. So, Here is what I have:

int main() {
string myString;
char *strPtr;

cout << "Enter a string to evaluate: " << endl;
getline(cin, myString);

[Code] ....

View 10 Replies View Related

C++ :: Extracting File Name From Path?

May 17, 2013

I have a string like this

const char *filename = "C:/Qt/progetti/worlds/fasr.world";

then I have a string like this

char *pathdir = "C:/Qt/progetti/worlds";

I would get this string: "worlds/fasr.world" how should I do ?

View 6 Replies View Related

C/C++ :: Extracting Strings From Files

Feb 15, 2013

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

[Code] ....

View 1 Replies View Related

C++ :: Extracting Decimal Numbers From A String?

May 16, 2014

Extracting integers from a string is trivial, but I am unable to find a function or code that will extract decimal numbers from a string.

I have a string that looks something like this:
" Asdf 1 1.3825 4.0000 12.0000 1.9133 0.1853 0.9000 1.1359 4.0000 "

Any tips on extracting the numbers (in decimal form) and storing them in a vector?

View 5 Replies View Related

C++ :: Extracting Polynomial Coefficient From String

Nov 30, 2013

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

View 10 Replies View Related

C++ :: Extracting String From Text File

Jun 5, 2014

I have a program here that writes employee information into a text file called employee.txt. I don't have a problem writing into the text file.

I'm supposed to enter the employees ID and search for it. Then pull up all they're info.

This is what I have.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
ifstream inFile;
ofstream outFile;

[Code] ....

This is the text file
Viktor,Luc,552,123 Home,5000
Joe,Luc,553,123 House,7000

View 7 Replies View Related

C/C++ :: Extracting Information From Data File?

Apr 20, 2015

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;

[code]....

View 1 Replies View Related

Visual C++ :: Extracting Stuff From IHTMLDocument2?

Feb 20, 2013

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.

View 2 Replies View Related

Visual C++ :: Extracting Time Stamps From PDF?

Apr 26, 2013

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)) {

[Code]....

View 14 Replies View Related

C :: Decrypting / Extracting Custom File Formats

Sep 25, 2014

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,

Code:
static const u8 unigine_mask[] = "xffx7fx3fx1fx0fx07x03x01";
u32 unigine_key = 0xa13cdbde;

Looks like a password of sorts. You then have to work out the complete understanding of the file formats, headers, blocks etc.. How is this done...

View 4 Replies View Related

C++ :: Extracting Nibbles (Number Represented In Binary)

Nov 29, 2013

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?

View 11 Replies View Related

Visual C++ :: Assigning Values To And Extracting Them From A Vector

Nov 28, 2012

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.

Code:
#include <iostream>
#include <iomanip>
#include <ctime>
#include <vector>
#include <cstdlib>
#include <string>
using namespace std;
const string name[4] = {" ", "rock", "paper", "scissors"};
const string roundResult[3] = {"computer win", "player win", "tie"};

[Code]....

View 1 Replies View Related

C++ :: Extracting From Loops - Run X Number Of Times And Produce A Prize Each Time

Sep 19, 2013

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.

#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
cout <<"Option A: Drop one chip into one slot" << endl;

[Code] .....

View 2 Replies View Related

C++ :: Multiple Of CSV File Used As Input / Extracting Data To A Output File - Getline Function

Jun 4, 2013

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?

View 11 Replies View Related

C++ :: Extracting Specific Lines Of Text From A Text File

Aug 2, 2014

I have a text file called (Test.txt) with the following text:

This is line one
This is line two
This is line three

How do I go about writing a program that will print a line of text (e.g. "This in line two" on the console screen?

All I can seem to do is display the entire text file.

View 6 Replies View Related

C++ :: Create Array Of Playing Cards / Assign Values And Suits Then Shuffle The Array

Nov 24, 2014

I got this program to create an array of playing cards and assign the values and suits and shuffle the array. I'm at the point where I need to output the cards but I need to burn the first card by making it output "**" instead of the card. my cards[] is a constant so I can's assign the first card as such.

void showCards(const int cards[], int numCards, bool hideFirstCard) {
if (cards[0]) {
hideFirstCard=true;
cards[0] = '**';
} for(int a = 0; a <= numCards; a++) {
cout >> showCard(cards[a]);
} }

View 1 Replies View Related

C++ :: Accept Integer Array And Its Size As Arguments And Assign Elements Into 2 Dimensional Array

Jan 10, 2015

Write a program using user-defined function which accepts an integer array and its size as arguments and assign the elements into a two dimensional array of integers in the following format: If the array is 1,2,3,4,5,6, the resultant 2D array is

1 2 3 4 5 6
1 2 3 4 5 0
1 2 3 4 0 0
1 2 3 0 0 0
1 2 0 0 0 0
1 0 0 0 0 0

View 1 Replies View Related

C++ :: Write Function That Takes Array And Returns True If All Elements In Array Are Positive

Jan 21, 2013

Write a function that takes an array and returns true if all the elements in the array are positive, otherwise, it returns false.

View 6 Replies View Related

C :: Store Character Array In Reverse Order Then Display Reversed Array

Jun 14, 2013

The program should store a character array in reverse order then display the reversed array. I have also included in the code that will display the actual characters into the array as it loops through. So I know the characters are being stored, but why doesn't it display the entire string when I call it?

Code:
#include<stdio.h>
int main(){
char str[50];
char rev[50];
printf("Enter Desired Text: ");
scanf ("%[^

[Code] ....

Is it just my compiler?

View 5 Replies View Related

C :: Parsing Char Array To Array Of Struct To Process Packets

May 28, 2013

I wrote this simplified version of a program i am writing that parses data in UDP packets. In the process of doing so i pretty much answered all my questions and fix all the problems i was having.

decodeSystemMap function will be in loop, and will proccess packets that have mostly the same data, only a few items will be added or changed or deleted.

whats the best way to check if there are any new, deleted, or removed items in the packet and only modify those?
Is there anything unsafe / dangrous about the way the code is now?

Code:
/* * File: main.c
* Author: david
*
* Created on May 23, 2013, 11:57 AM
*/

#include <stdio.h>
#include <stdlib.h>

[Code] ....

View 4 Replies View Related

C :: How To Make A Function Read From Array A But Put Select Parts In Array B

Jul 30, 2013

im trying to read in 1 array and get 2 as outputs from 3 different functions.my read array is easy enough were im getting confused is how to read that array, separate it and take out only the parts i want and place them into a 2nd, then again a 3rd array.i have the following so far:

Code:

#include<stdlib.h>#include<stdio.h>
#include<unistd.h>
#define SIZE 10
}

[code]....

this compiles without a complaint, but when i go to run it no longer responds after taking the 10th element (well 9th if counting from 0).I think i have the if correct for the even odd section, but when i try to populate B or C array with the output of that if statement from A is were i think things are dying...

View 12 Replies View Related

C++ :: Storing Numbers Into 2D Array - Invalid Types Int For Array Subscript

May 17, 2014

#include <iostream>
#include<fstream>
int decryption(int);
int multiply(int,int[][2]);
using namespace std;
main(){
int n;
ifstream inFile;
inFile.open ("out.txt");

[Code] .....

I was trying to store numbers read from a text file into 2D array but I am getting the error above.here is where the error occurs:

line 33: cout<<m[i][j]<<" ";

View 4 Replies View Related

C++ :: Using Loop To Process Array Of Characters Starting From Beginning Of Array?

May 3, 2014

Assume you want to use a loop to process an array of characters starting from the beginning of the array. You want the loop to stop when you read the null terminator character from the array. Fill in the loop test condition that will make this work correctly.

index = 0;
ch = array[index];
while ( _____________________________)
{
// process the character
index++;
ch = array[index];
}

View 1 Replies View Related

Visual C++ :: Reading Into Array / 2d Array From Mixed Text File?

Jan 18, 2014

I know to read a strings into array and tables.. what is they are mixed up?? strings are just names ( 3 characters) and there are bunch of table.. the max size was set to 60

ex. text file

JES
DAN
JEN
.
.
.
01010101
10010101
RAM
JET
01010010
10100101
.... and so on

should i use a while loop?

View 10 Replies View Related

C++ :: Multidimensional Array - Moving Whole Int Array Row As A Single Unit?

Feb 27, 2013

I have a multidimensional array that runs parallel with a string array

Lincoln 120 300 400
Parks 100 500 250
Shakespeare 0 30 50
Ghandi 250 100 40
Ashe 300 50 175
Rodriguez 87 118 320
Curie 284 0 112

I need to sort this and I know how to do it. But I need to sort it again with the highest value in the first row and keep all information in that row paired with the name . So

Lincoln 120 300 400
Parks 100 500 250

Parks 100 500 250
Lincoln 120 300 400

I need so swap this whole rows. I'm using dynamic array. So my question is Do I have to do a bunch of temps to move them? Or is there a way to move the whole int array row as a single unit?

View 3 Replies View Related







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