I am currently trying to read information from an ID3V1.1 tag in C. For this project we are not allowed to use any external libraries. All of the fields except for the track field read correctly. The last two lines are the ones giving me trouble. Whenever I run the program, I get a seg fault when it tries to get the track number. I tried to debug using gdb and it said the problem was happening on line 34 which is where the fseek is. It works for the other fields so I'm wondering why it is going wrong. Should I change the offset to something other than -128? But the whole tag is only 128 characters so I'm unsure what is going wrong.
Code:
Program received signal SIGSEGV,
Segmentation fault.0x00000034ff66edf1 in fseek() from / lib64 /
libc.so .6 Missing separate debuginfos,
use:debuginfo - install glibc - 2.12 - 1.132.el6_5 .3.x86_64(gdb) back
#0 0x00000034ff66edf1 in fseek () from /lib64/libc.so.6
#1 0x000000000040076f in main (argc=1, argv=0x7fffffffdf58) at id3tagEd.c:34 Code: Code: #include<stdio.h>
#include<string.h>
}
I am trying to write a program that will read the id3v1 tag of an mp3 file, output the current information, and then allow the user to edit the ID3 tag. I can get it to output the information but I'm having some issues getting it to edit correctly. It seems to try to edit the wrong fields.
#include <iostream> #include <fstream> using namespace std; int main(){ int end; ifstream myInputFile; myInputFile.open("01-Cheeseburger in Paradise.mp3", ios::in);
i am trying to make a hangman game. The game works fine so far but i cannot seem to keep track of the letters used. I have to prevent the user from using a letter that has already been entered by the user at some point in the game before. But can't seem to work my way around it. I have included the code below
This program is suppose to read a matrix file , and the first getline is suppose to get the file header but it appears that 'line' doesn't take in any value other than empty thus causing all the problem , I tried to put cin.getline() in front of it to take away the /n created by the cin before it , but it doesn't work . When I debug the program when the arrow points to the string line , this error appears
line<Error reading characters of string.>std::basic_string<char,std::char_traits<char>,std::allocator<char> >
I tried to initialize string line=NULL too , doesn't work either.
I am working in Eclipse, and it keeps giving me this error that I do not understand. In the fillTable function, "is >> kP[i]" Eclipse says: no match for 'operator>>' in 'is >> *(((TranslationTable<int, std::string>*)this)->TranslationTable<int, std::string>::kP + (+(((unsigned int)i) * 8u)))'.
I am trying to record some information in a file and allow user to delete a record. I am facing this message in Autos section of MVS (Error reading character of string). Here is the code:
int removeRecord(string name, int &row)//remove a record { const string data="database.txt"; fstream records; records.open(data.c_str()); const string cpData="temp.txt";
[code].....
If I delete the any row (except last roe) it works but then add a copy of last record (sometimes fully sometimes partially) at the end of the file!! if i delete the last record it does not do anything.
does a pointer keep track of time stamps when it is created? i am trying to use it to create a table that can store the access count and the temporal locality at the same time.
I would like to track user actions within my windows desktop application, and write them to a database.
I also have a User class, that has a userID field pulled from the User table. I can write a login event (UserID, timestamp, action) with no problem, but as the user navigates around the app, how can I persist the user object so I always have access to their userID? I know I can just pass it as a parameter as they do different tasks, but that seems inefficient to me.
Code: #include <stdio.h> #include <string.h> #include <stdlib.h> int encrypt_data(FILE *);
[Code] ....
I am trying encrypt the file "encrypt" when I enter it I get "Error in reading file"
I think its a problem with the fgets() and scanf()...I tried both fgets out and then scanf but I get the same error.
I look in the directory and see that when I enter a file to be encrypted a blank file with a "?" at the end is created in the directory. so I try to encrypt "encrypt" it shows error then creates "encrypt?"
I then tested it by entering a random file name that does not exist
EXAMPLE
Please enter file to be encrypted: fakefilename
Error in reading file.
I look in the directory the non existent file now is listed "fakefilename"
I am using OpenCASCADE environment to read STL file! I face a problem, with forward declaration error with the following
void StlReadIn::STL_Import() { std::string FileName; std::cout<<" Enter the file name "; std::cin>>FileName;
[Code] .....
Error message:
stlreadin.cpp:26:47: error: invalid use of incomplete type ‘struct StlMesh_Mesh’ /usr/local/oce-0.9.1/include/oce/Handle_StlMesh_Mesh.hxx:23:7: error: forward declaration of ‘struct StlMesh_Mesh’
Below is the code for reading a struct that was stored in a binary file. Problem is while reading from file I get the name without first character and age is always equal to zero which it should not be.
I am writing to write a program and performs the following tasks
- Reading a file (txt file contains some temperature values) - Display the temperature values (contents of the file) - Calculating the average of the temperature values in the file. - finds the maximum and minim value of temperature in the file.
The program is user interactive and waits for the user input and process according to his input (choice)
I have managed to complete the program and covered all the expect except the error handling for file opening and reading, although I have managed to do it for the part one part (i.e for the choice == 1)
I can repeat it for the other choices (i.e for 2, 3 ) but I do not want to repeat the code and do it in a different function or do it once for all. While making an attempt I can not handle the rest of the program and all the program turns into a mess.
#include <iostream> #include <fstream> #include <iomanip> int menu(); int myChoice(char); char inputValidating();
[Code] .....
Need Error handling for file opening and Reading that is used once, So far I have managed to do it for choice 1
I have a set of n- dimension point store in `vector< vector<double> >`
ex A[0][1].............[N], and A[0][0] = X, A[0][1] = Y, A[0][2] = Z
and I want to sort the vector of all of the dimension
ex sort X, Y, Z ,.........N in ascending order
ex A[0] = (1,5,3), A[1] = (3,2,1) A[2] = (2,8,4) after sorting index: 0 1 2 A[0] = (1,5,3), A[1] = (2,8,4) A[2] = (3,2,1) original index : 0 2 1
I find that `sort(vector.begin(), vector.end())` can sort it but how can I record the original index with a additional vector?
Is there a algorithm or C++ feature can solve it?
I have tried to solve it with a class wrapper it but I don't know how to write the compare function.
class point{ public: point(int totalLength = 0, int elementLength = 0); vector<vector<double> > pointSet;//store the n-D points vector<double> pointIndex;//store the index }; point::point(int totalLength, int elementLength){ pointSet.resize(totalLength,vector<double>(elementLength, 0)); pointIndex.resize(elementLength); }
I am trying to write a program that keeps track of social security numbers of customers I have to assume that its a four-digit number. When the program runs,it has to prompt that the user should enter a 4-digit number to record, or 0 to exit.
The program also needs to be able to give an error message if a certain number is entered more than once.
After all the numbers have been saved and you finally end it by pressing 0, it needs to be able to output all the entered SSN's.
Here is my code so far:
#include <iostream> #include <iomanip> #include <cmath> using namespace std; bool isExist(int ssn, int records[], int numberOfRecords);
In this assignment, you are going to write a program that keeps track of the social security numbers (SSN) of customers of a bank. Please notice that we are going to assume that SSN is a four-digit number (e.g., 1234. 0123 is not allowed.). When the program runs, it prompts that the user should enter a 4-digit SSN number to record, or 0 (zero) to exit.
So far I have this:
#include <iostream> using namespace std; bool isExist(int ssn, int records[], int numberOfRecords); int main(){ int ssn = 0; int records[32];
I wrote a code that mimics a dice, my code so far will ask for the user to input a number at which they want to hold or no longer throw the dice, it will also ask the user how many roll simulations they would like to do.
If a 1 is rolled the turn is over and the score is 0
After this input is recieved the code goes into a loop until the values have been met.
I would to add probability to my code so I need to know how many times a certain number was rolled and this is where I am stuck.
An example of how I would like my code to work, let's suppose hold at number is 17
We role the dice until we roll a 17 or larger, but if we roll a 1, then our score is 0.
Let's suppose the number of simulations is 5 and for simulation 1 we roll
2 + 5 + 6 + 4 = 17
and for simulation 2 we roll
5 + 4 + 1, but since we rolled a 1, the score is 0,
for simulation 3 we roll
3 + 4 + 5 + 6 = 18
for simulation 4 we roll
4 + 4 + 6 + 6 = 20
for simulation 5 we roll
3 + 4 + 5 + 5 = 17 so that means we got
0: 1 time 1/5 = .20 17: 2 times 2/5 = .40 18: 1 time 1/5 = .20 19: 0 times 0/5 = .00 20: 1 time 1/5 = .20 21: 0 times 0/5 = .00 22: 0 times 0/5 = .00
In other words the idea is to roll a 17 or larger (or whatever the hold number happens to be), but if you roll a 1, then your score is a 0.
#include <iostream> #include <cstdlib> #include <ctime> using std::cout; using std::cin; using std::endl; int dieRoll();
I am trying to write a program that keeps track of social security numbers (SSN) of customers of a bank. I have to assume that SSN is a four-digit number (e.g., 1234. 0123 is not allowed.). When the program runs,it has to prompt that the user should enter a 4-digit SSN number to record, or 0 (zero) to exit.
The program also needs to be able to give an error message if a certain number is entered more than once.
After all the numbers have been saved and you finally end it by pressing 0, it needs to be able to output all the entered SSN's.
Here is my code so far :
#include <iostream> #include <iomanip> #include <cmath> using namespace std; bool isExist(int ssn, int records[], int numberOfRecords); void listRecords(int records[], int numberOfRecords); int main()
im trying to read employee information from a file using structures but im having problems with getting the file to open and read in the information
Code:
Write a programt that inputs (at most 50) records from a sequential file #include <stdio.h> #include <stdlib.h> struct employee // employee structure definition }
I have this image/video compression project that is to be done in C. I've been given this source code by my supervisor which is supposed to be a working one.
Assuming I have a sequence of 5 images in .pgm format (image41.pgm, image42.pgm .... image45.pgm). Some of the code involved is
When I tried to compile the code using make file (shell script), I got this error message "In function 'readPgm' format '%d' expects argument of type 'int *', but argument 3 has type 'unsigned char *' "
Can identify what the problem is and how to rectify it?
I'm trying to keep track of the size of blocks of memory that a pointer points to. No matter what I do, this code below always outputs the integer 8.
If I change 1000 to 5, I still get 8. If I change it to 0, I get 8... If I change it to -1, I get 8. If I change int *a to double *a, I get 8. If I take away the & symbol, I get 8. If I use *& instead, I get 8.
Why? I want it to output 1000. If I change that to 500, I want it to output 500.
int *a; a = malloc(1000 * sizeof(int));
int j = sizeof(&a); printf("%d", j);
I want to build my skills where I can allocate, inspect and change memory sizes.
Cannot manage to find the error source when i try running the program, the first part of the program runs just fine its when i try to get the temperature one that i get the error
#include <iostream> #define pi 3.141592 using namespace std; int main() { double r, h; //declare variables for radious and height double Surfacearea;
I've just recently started to learn C++, and I'm encountering some errors I can't seem to figure out.
InventoryItem.h:
Code: #pragma once class InventoryItem { public: InventoryItem(string name, int amount); ~InventoryItem(void); string getName(void); int getAmount(void);