or better yet, what if I want it to not matter whether the columns are separated by commas or spaces? is there any way to do this? If there is no way to read in both comma-separated and space-separated elements simultaneously then I would prefer just comma, rather than the space separated which my code is able to read now. What modifications would I have to make to my code to make this work? This is my code to reference.
I am attempting to read in a file that has 4128 sets of 21 numbers separated by commas and write it into an array. I now know that in order to use fseek, I have to make my array a character array, but I need my function to read in decimals (ex: 0.172635). I'm reading in
I have been trying to read a comma separated .txt file into an array and print it to console in C++. The txt file consists of two columns of double type data. For some reason the program runs, but gives blank output in the console. I want to know if I am doing something wrong. So far this is what I have:
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { int i=0; double x[10]; double y[10]; string line;
I am wondering about the constructor. I see there appears to be nothing inside of TinyGPS::TinyGPS() as far as parameters go and that that declaration is followed by a ":". First I'm wondering as to the meaning of the colon. As well with the variables defined after the ":" I see some "(0)" and I am wondering as well to the exact meaning of the "(0)". Are those variables being defined as parameters separated by ","?
I'm trying to enter an 'x' and 'y' coordinate on only one line separated by a comma. But I keep getting a syntax error. Here are the lines of code I'm using. This has to be simple. What am I doing wrong with this code?
Code: cout<< "Please enter the x and the y coordinates of the first point,"<<endl; cout<< "use a comma to separate them. " <<endl<<endl; cin>> "You entered: " >>x1>>",">> y1 >>"for the first point" >>endl;
I am having trouble reading in a file of 10 names into an array. Ive already allocated the memory, I just keep getting a seg fault when I try and read in the names.
I have a file with data in lines separated by commas and im trying to print out specific lines and specific parts of data from that line. I need to isolate lines where the first column of data reads '$CPGAR' and print out specific data columns.When I print out the strings I get random data and my strcmp to isolate lines isnt working? Im very new to this, heres a sample of my program:
while (!feof(gpsH)) { char word1[10],word2[10],word3[10],word4[10],word5[10],word6[10],word7[10], word8[10],word9[10],word10[10],word11[10],word12[10],word13[10]; char a[6] ="$CPGAR"; /* read data line */ fgets(gpsS,10,gpsH);
In the usual case, its an easy problem. But it gets tricky in my case, since I am working with numbers up to 30 digits, unable to store them in any int, long, long long. Due to this obstacle, the user inputs a number and each digit is stored in my array individually.
I need these commas to print as I am cout the array. This means I only have array length to work with.
I want to use modulus, but I'm not sure how this would work. I have:
void prArray(int Array[], const int arrSize) { int mod = arrSize % 3; int remainingSize = arraySize; int counter = 0; for(int i=0; i <= arrSize; i++){ remainingSize--;
[Code] ....
Which outputs the first digits correctly, but leaves 4 digits at the end: 235423452345 -> 23,542,345,2345
i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile.
void Store::deleteSpecifiedStoreFromList(string choice) { for (int i = 0; i < this->stores.size(); i++) { if(this->stores[i].getStoreNames() == choice) { this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() ); } } }
I am trying to create an array of file names such that when I want to open one of the files, who's name is given in the array, I can call that element of the array. My code for making the array is the following,
Code: char file_name[40]; char *file_locations[N]; // array of N names (*) for(ii=0; ii<=N-1; ii++){ // printing the names of all the files P1_8mag_1.txt - P1_8mag_N.txt sprintf(file_name, "P1_8mag_%i.txt", ii+1);
[Code]....
The problem with this is that in the first step: all elements of the array "file_locations" are the name of the last file in the loop (in this case "P1_8mag_N.txt")What is wrong with this?
I am trying to make a for loop that will print out chars in an array while using a #define before main. My problem is that each name has a different amount of chars in it. How do you account for that when you are trying to define a size? For example, I am playing around with the numbers and I just put 7 in for size:
/* Implementation of a circular queue of Array containg names.. */ # include <stdio.h> # include <conio.h> # include <stdlib.h> # include <string.h> # define QSIZE 5 typedef struct{
[Code] ....
I changed my code. but whenever i typed in the ILoveBacolod it takes it as a whole, and if i deleted it deletes the string not the letter. for example:
Enter String: ILoveBacolod Enter a command: Delete (D) Output: LoveBacolod Enter a command: Delete (D) Output: oveBacolod Enter a command: Add (A) Enter a character: z Output: oveBacolodz
I want to create 2 functions to (1) convert a passed string into proper case (capitalize the first alpha character of a string and every alpha character that follows a non-alpha character); (2) sort the array of names (after it has been converted to proper case).
I am having a hard time trying to get data into an array of objects. The data file has 3235 lines, state, fips code, and county. The state and fips code are getting stored correctly but some countys have 2 or more words in them (now noticing the "and" is missing from one of them.
Trying to append a comma to a string. Getting "Segmentation Error" on Solaris when the function is entered the second time.
Code:
// Appends a comma to the given string void appendComma(char* instring) { if (instring == NULL) { instring = realloc(NULL, strlen(",")); strcpy(instring,",");