I'm a programmer on my high schools FIRST Robotics team. to give a bit of backstory if you don't know, we use C++ to program a 120 lb robot to compete in a competition released every year.
NOW - why I want to mess with an xml file. When we're messing with variable values to make sure everything moves at the right speed, stops at the right place, etc., we have to:
1. Change the file
2. Build code
3. Deploy code to the robot
4. Reboot the computer on the robot (FRC uses a 4 port cRIO by NI, takes ~ 50s to reboot)
5. Reconnect.
All in all, its about a 3-3.5 minute process to change values. Because of this, I would love to be able to store all my motor speeds, stopping positions, etc., in an xml file then simply ftp to the robot, mess with the xml, save it, and re-run the program.
SO! How would I even begin this process? I just want learning how to use one of those parsers like xerces to end up realizing that I can't use it in an application such as this.
I am trying to write a program that will open a file with 2 points, take those points, determine what quadrant those points are in, and save the result back into the same file without truncating the data.
I'm having some trouble with my file I/O. I can't get my program to read the two values for X and Y that I put in the points.txt file. It simply uses whatever random number was used last time in that block of memory. In my points.txt file I put something like "4 -5" and it wont assign those numbers to my X and Y variables. I believe the issue is on line 25
#include <iostream> #include <fstream> using namespace std ; int main() { //defining X and Y double X, Y ;
I am having problems writing this program for class the program must read a DAT file and print the Array and show the sums of A and B and the smallest and largest of the numbers in the DAT file
this is what it is suppose to look like after compiled
Array A[]: 60 40 80 100 30 20 90 50 10 70 Array B[]: 15 95 35 -10 45 -5 85 75 65 55 -20 25 5 25 -15 Sum of the elements of A[] = 550 Sum of the elements of B[] = 475 The smallest element of A[] = 10 The smallest element of B[] = -20 The largest element of A[] = 100 The largest element of B[] = 95
but this is what I get..
Array A[]: 60 40 80 100 301845634224184564560018456342248463648 1 Array B[]:3994112184685425110290441628889523994216 0 03994108399426418511697 04 -1184564557518455763132047600601153318 Sum of the elements A[] =1250410711 Sum of the elements B[] =-475173273 Smallest element of A[] =1845634224 at index 5 Smallest element of B[] = 0at index 5 Largest element of A[] = 1 at index 9 Largest element of B[] =1851169704at index 9
I want to search for the "movie_code" and change the [movie_status] from Active to Inactive.
So lets say for example i have a movie code 12345 saved in my movie file. I want to change the value from "Active" to "Inactive"for argument sake.
This is the code i was trying to do it with:
FILE *movie_fp; movie_fp = fopen("movie.dat", "r+b"); int m_code; MOVIE movie_data; printf("*** Welcome to the movie updater! *** "); if(movie_fp != NULL){
My problem is that I need to take a csv or excel file with tens of thousands of datapoints, write all points in a section of column to an array, perform calculations on them, and then write it back into another column.
I've been looking all over the internet for ways to do this easily. So far I have not found anything that I can follow and implement.Some codes have been slightly useful, but they aren't commented in a way I can understand. How to write code to take, for instance, lines from column b between 500-1000, write them to an array, and write another array 500 characters in column c. If that code could be commented, I have tried a few different techniques (counting commas), but haven't gotten anything to work.
I have a .txt with a 0 or 1 to each line of the txt file. there are many values to read. I am reading the values and calculating how many each reoccur in a sequence (run-length encode). If i only use say 50 values coming in it works, but once i do the hundreds there are in the file it hangs. i am not sure why.
I read one csv file in which it contains different types of data like string, integer etc.I want to fetch only integer data from that file and store in vector.Below i copy some code that read line from file,store in vector.I tried to convert string to integer or double and do some operations on it as i know that string values,but how to identify only integer values and store that in vector?
#include<iostream> #include<vector> #include<string> #include<fstream> #include<sstream> #include<iterator> #include<algorithm> using namespace std; int main() { string line; int cnt=0,val1,val2;
[Code] ....
input file like Employee Code:121AEmployee Name :David DateInTimeOutTimeShiftTotal DurationStatus 01-Apr-139:5919:53FS 9:53 Present
I am trying to get my program to calculate what point goes in what quadrant using a file. But msy program is not reading the values from the file and also it is not running so im not sure what's wrong with it.
//This program uses a fstream object to write data that will read the values of a (x,y) point from a file. //add the appropriate preprocessor #include <fstream> #include <iostream>
in the following code how would i set a txt file up to where i can have say name = whatever in it and the program will find it and set it to the corresponding global value.
I'm trying to read values from a file to store them in an array in C++ and then output the values in a table format for everyday of the month: morning, noon, evening and night. My text file looks something like this:
I have a report that's generated by a piece of software, and (I'm assuming because it was intended for Linux/Unix) when I open to read it in notepad, it has a bunch of funky symbols in it, and incorrect line feed characters instead of returns that windows uses.
I looked at the txt file with a hex editor and can see all the hex codes for the symbols I want deleted. One of the symbols 0A.
How can I do a "find and replace" command but do it with hex codes? These symbols cant be simply placed into my code file because VS does not know how to interpret it.
This code is for fun, and have it doing a lot of what I want it to, just not all. I want random generated to write to a txt file. I tried to use an array but that failed. I wanted to use an array because i am only passing one value. Which makes sense since the random generated function is an int.
I made the fprintf as a comment but hopefully soon it will be able to send the values to the txt file. After that I will tackle the function.
Code:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define HIGH 49 #define LOW 1 int random_generated()
get my code to display a table with values from a file. my current code fills up all the sections of the table with the same data. here is what I need: from a file .txt I upload numbers that should show a table like this :
Lake Beach Average E-Coli Level Recommendation Ontario Kew Beach 47.12 OPEN Huron Goderich 51.13 CLOSED Simcoe Sibbald Point 0 INSUFFICIENT
my problem is in the last two columns. The ave. E-coli has one value for all which should look like the above table but my code doesn't. Also my recommendation shows the beach # instead of open close or insufficient.the data is:
We are supposed to split this lab into 3 files a .h and 2 .cpp's. The code I'll be talking about is going to be directed at the main.cpp file. Basically we are supposed to be able to enter as many classes into the program and when you are done the program is supposed to save the contents into a .dat file. This lab is working off of an older lab so I already have a .dat file I am trying to test with this program by reading it into my program when I first run it I prompt if the user wants to load previously entered courses and if they reply with a 'Y' the program will load the contents of the .dat file. Problem is right now when I load from the .dat file only the first class is correct. Every other class after that is just giberish. I've tried everything but can't get the restore part working. I also cannot get the save to .dat portion of this lab working either.Here is my code:
#include "Course.h" #include <iostream> using std::cout; using std::cin; using std::endl; using std::ios;
I am trying to read an array values from Tmin.txt file. I take array size from user viz. number of raw & column and then, read the following data from Tmin.txt file which look like this:
I would like to extract and analyse the data but the data behind the NUL entry is not accessible for me maybe due to the fact that NUL normally marks the end of a line. Is there a method to remove the NUL entries in this text file?
I am trying to read this xml file. This readFile function does not give me right values. Only to use cstring..no pointers or other libs such as xml libs
My game is a sort of RPG with stats, money etc. I just recently added a save/load system using writing to a file. I initially got writing to a text file to work, then I got loading to work too.I eventually was able to read numbers from the file and assign them to integer variables in order.
My issue was I wanted to check if a save file existed, if it did, load it up, if it did not, go to character creation. I had a lot of trouble with this and after trying different code snippets to work I finally got it to check if a file existed, and execute the appropriate code.
My issue now is my code USED to go through each entry and assign variables in order.
Like the first number in the text file would be for the variable money, and it would read it, assign to to int money and scroll to down to the next variable for player strength, assign to to playerstr variable and so on. After making the tweak for loading it no longer functions like this, and makes the last entry in the text file the value for everything.
I barely get how this code works, how can I tweak it to go through the file in order and assign variables one at a time?
At the current moment, it assigned the playerstr value to both money and playerstr int. But the save file being created lists the correct values in order.
My issue is now a segmentation fault in my sorting algorithm. In my assignment I was suppose to implement quick and insertion sort for the file, and organised strictly by ASCII values. We were allowed to look up generic algorithms for the sorts, but we have to convert them to comparing char arrays.
I haven't started trying to configure quick sort yet, but I'll supply the generic algorithm as well. keep in mind that the first line in the file contains the number of lines in the file. I'll try not to disappear this time!
I have chosen C# as our language . Students have to enter a name of a recipe, followed by the number of people it will serve, followed by a list of ingredients for a recipe. This, then, needs to be exported to a text file. This bit I am fine with.
They then have to import the file back into C# and recalculate for a new number of people. This is the bit I am struggling with. The calculation is fine, I can do that. The issue is getting it to loop around each column of data to not only perform a calculation (I have just set it up to multiply by an entered value for now). I have set up a text file with the following data in it:
I am trying to read hex data from a file (not just hex values in text format). I was able to read it (02 EC) with "fread" into an char before but I need to change the Hex value into an integer in decimal.
I already read about strtol but I would prefer reading the hex Value into an integer.
Here is my code so far:
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int itrack1[1]; int itrack2[1];