C++ :: Data Structures - File Size Not Decreasing When Erase A Record
Nov 26, 2014
// my size is not decreasing when I erase a record.
//dvr_hwch.cpp
#include <iostream>
#include <iomanip>
#include <cassert>
using namespace std;
#include "hash_chn.h"
void print_menu( );
[Code] .....
View 1 Replies
ADVERTISEMENT
Nov 29, 2013
I was wonder if I can make 2 different size structures in a file. I wrote a code but It's apart of my school project and I havent compiled it yet, so Im just wondering will this work?
Code:
if((stsPtr = fopen("status.dat", "rb")) == NULL){
prinft("File could not be created/opened.
");
Error();
[Code] .....
View 1 Replies
View Related
Aug 24, 2013
I'm still learning intro to C language. Currently I'm having problem with my code. The task is to ask user to input information about staff and write them into a text file. The problem occur when:
1) output in text/.exe file display random characters.
2) Data obtained from New_Staff unable to pass into Export_Profile.
3) a new output will overwrite the existing information in the text/.exe file
4) the delete function unable to delete correctly after the first time i delete a staff information in text file.
The code is as follows:
#include <stdio.h>
#include <stdlib.h>
void Menu();
void New_Staff();
void Delete_Staff();
void Export_Profile();
[Code] ....
View 4 Replies
View Related
Feb 25, 2015
Why I do have this error message?
1>------ Build started: Project: TMA04, Configuration: Debug Win32 ------
1>TMA04.obj : error LNK2019: unresolved external symbol "double __cdecl getFees(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getFees@@YANV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>C:UsersEvgericDocumentsVisual Studio 2010ProjectsTMA04DebugTMA04.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
View 1 Replies
View Related
Nov 2, 2014
I'm reading the following file:
Osgood,Marcus 298542123 CHM FR mosgood@whatever.edu
Cronk,Melissa 873489021 BIO SR mcronk@whatever.edu
Pry,Seth 349908431 MTH SO spry@whatever.edu
Langlais,Susan 783323545 ME SR slanglais@whatever.edu
Davis,Nicole 987543345 PHY FR ndavis@whatever.edu
It's supposed to split it up into name, ID number, major, year, and email. The file reads it without any errors, and assigns name to the first part of the structure. However, ID gets assigned the ID, major, year, and email. Then Major gets assigned major, year, and email. Year gets assigned year and email, while email just gets assigned email. I don't know if it has something to do with the loop. For example, this is what I get what I print just the name and the ID.
Cronk,Melissa 873489021BIOSRmcronk@whatever.edu
Pry,Seth 349908431MTHSOspry@whatever.edu
Langlais,Susan 783323545ME
Davis,Nicole 987543345 PHYFRndavis@whatever.edu
Anyway. This is my function code for reading the array. I have it printing the ID number just to see if I can catch the errors earlier:
Code:
#include <stdio.h>
#include <string.h>
#include "functions.h"
void read_data(char filename[], studentinfo_t s[], int *size) {
FILE *infilep;
int countstudents = 0;
infilep = fopen("student_data", "r");
[Code].....
the name is reading correctly, but not anything else!
View 1 Replies
View Related
Sep 5, 2013
I am doing a project which I have to read, write and erase data from a NorFlash Memory. Then, I have to compare those data files in order to find errors.
Besides, I would like to know which is the best way to TEST errors in this kind of memories.
I am using NetBeans 7.3.1 for writting the code and Cygwin running on Windows XP Virtual Machine. The Memory Flash (S29JL064J 64 Megabit) is incorporated on an external board which is connected to an adapter board (using HDMI cable). This adapter is connected to the Laptop (using an USB).
View 3 Replies
View Related
May 13, 2012
I am trying to read from a data file that has input as :
12.0, 11, 123
14.0, 12.1, 3
And I want the program to read the data from the file and then make it into an array of structures and then print that array afterwards.
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_INPUT 1000
int n =0;
int i = 0;
typedef struct {
double x[MAX_INPUT];
[Code] .....
The program when run gives the following output:
Ishtiaque-Mohammed-Khans-MacBook-Pro:Comp20005 IshtiaqueMKhan$ gcc -Wall -ansi -o ProjectB ProjectB.c
ProjectB.c: In function "main":
ProjectB.c:59: error: incompatible type for argument 1 of "print_array"
View 1 Replies
View Related
Dec 4, 2013
I have a program that stores health information the user inputs, one person at a time. The program works perfectly with the exception of storing the data...I need to open a file and read what health data it has in it already, if any, but store the new changes, and appended data to the array of structures, to the data in memory. All of the information is only saved back in the file once the program terminates. I'm not sure how to go about doing this, so I am also not sure what to put in the function for "Save and Exit" that the user can choose in order to exit the program.
Code:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct strdatabase
{
char first[20];
char last[20];
char gender[2];
[Code]...
I tried playing around with this bit of code, but I'm not sure if I'm even on the right track.
Code:
FILE *fp;
fp = fopen ("students.txt","rb"); fseek(fp, 0, SEEK_END);
long pos = ftell(fp);
fseek(fp, 0, SEEK_SET);
char *bytes = malloc(pos);
fread(bytes, pos, 1, fp);
fclose(fp);
View 9 Replies
View Related
Feb 4, 2013
Well, I have a .txt file that contains, together with a few characters, columns of values that I want to save in different files like is written in the program (file 1, file2, file3 - a with x, b with y, c with z). BUT, I don't want the values from the lines with the saying "interpolated_vector" to be printed in any of the three files.
What I have is the code below, that has the code that creates the three new files with the columns of values that I want. It is working fine!
Code:
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
int i, count;
double *a, *b, *c;
double *x, *y, *z;
char tag[5][255];
[Code]...
I've tried and tried, but couldn't make it work properly. I could only erase one line with "interpolated_vector" using fgets, but all the other lines below this were printed into the three new files (file1, file2, file3).
View 5 Replies
View Related
Sep 24, 2014
How to validate the data if the data already exist in the table record in c#?
For example I wanted to add the student roll no. if roll no. is 134 and if we are adding rollno. 134 student then we get the warning like roll no. 134 is already exist ....
View 1 Replies
View Related
Jul 2, 2014
I created one structure and the created structure is using in few more structures, but i did not get the proper data.
typedef struct _MSG_HEADER{
//MESSAGE_HEADER 40 bytes
short iApiTcode;
short iApiFuncId;
int LogTime;
char AlphaChar[2];
[Code]...
My requirement is have to fill the MessageHeader structure & we can use that header in all the structures entire program.
View 3 Replies
View Related
Dec 4, 2014
I'm taking a programming class and currently we're doing data structures. Today, we discussed how to save square matrices column-wise with data structures. The teacher said that after the first few steps where you declare the structure, allocate the matrix, free it and get the dimension (which mostly make sense to me I think), you have to "get" and "set" the matrix by putting in something like
Code:
void setMatrixEntry(Matrix* A, int i, int j, double Aij) {
A->entries[i+j*A->m] = Aij;
}
[Code]....
View 7 Replies
View Related
Oct 26, 2013
I need an explanation of what linked lists are. How the nodes are been defined and used, especially in an object oriented programming. With a code example.
View 1 Replies
View Related
Feb 17, 2013
I want to have input data stored in a database. All information entered is to be stored under a single block. That way whenever I want to recover that information all I have to do is point to that block. Think of it like this. I want a large square block that can hold certain information. Inside of that large block are a finite amount of smaller blocks in which the user entered information about a single subject. Lets say block 1 has a name, address, and phone number. The second block will have the same TYPE of information, but different values as entered by the user. I.E:
BLOCK 1: Name 1, Address 1, Phone 1
BLOCK 2: Name 2, Address 2, Phone 2
etc.
The large block contains all of the smaller blocks, we will name the large block "Address Book" ... How would I implement that? Of course it would be just a simple console program that would erase all information when the program shut down, but I've been trying to figure out how to do it, but just can't seem to grasp a good notion of how to do it. What would be the best way to do that? Structures? How would I make it dynamic so that I wouldn't have to define every block, so that it would be added on the fly when someone inputs new information.
View 2 Replies
View Related
Apr 18, 2014
I'm working on a program using class booktype... to hold information about various books that I have saved on a txt file. Each object of the class book type holds the author, publisher, ISBN, number of copies in stock.
I am still very much new at c++ and not exactly sure how to get in info from the file I've made earlier..
Code:
#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
#include<fstream>
using namespace std;
class bookType {
Also the text file is formatted where after I've entered the author's name I then hit return, then publisher then I hit return, ISBN then return, and so forth does that effect the program? As for my txt file this is what I have
Code:
Moby Dick
Sebastian Armesto
Oberoson Books Ltd
0001
201
The Scarlet Letter
[Code] ....
View 6 Replies
View Related
Dec 6, 2014
Code:
#include <iostream>
using namespace std;
int j;
int n;
int recursive ( int arr[j] );
int main() {
int i;
int arr[10000];
[code]....
This is how I tried making the program..
I want it with a recursive function
I want if the sequence is non decreasing return true else return false
View 10 Replies
View Related
Apr 16, 2014
We're writing a program in class using data structures and arrays and I'm stuck on writing a loop to find the students' highest test score. I only return the first student's ID, test score, and grade. For some reason unknown to me I'm not actually looping through all 12 or so records.
Code:
#include <stdio.h>
#define MAX_ENTRIES 50
struct records
{ //declare my student records structure
int ID; //the student's ID number
int test_score; //the student's test score
char grade; //the student's letter grade of aforementioned test score
};
[code]....
View 5 Replies
View Related
Sep 26, 2014
typedef struct example_dt_struct {
int a;
float b;
char* c;
};
typedef void(*func)(example_dt_struct *s, int e, int f);
void f(func *n){}
how can i use example_dt_structure with my function pointer into f()
View 5 Replies
View Related
Feb 3, 2014
So this makes an output of the head (a square), and the leg (rectangle. How do I make my points into a data structure in the shortest yet simplest way possible?
#include <vector>
#include <time.h>
using namespace std;
#include "Glut_Setup.h"
float
head1x= -0.5, head1y=3, head1z=0,
head2x= 0.5, head2y=3, head2z=0,
head3x= 0.5, head3y=2, head3z=0,
head4x= -0.5, head4y=2, head4z=0;
[Code] .....
View 10 Replies
View Related
Feb 27, 2014
So I made a code that shows a simple rectangle. How do I make it move using data structures? :)
Code:
#include "Glut_Setup.h"
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <time.h>
using namespace std;
float P1= -5;
float P2= 2;
[Code] .....
View 2 Replies
View Related
Apr 8, 2014
I am trying to read the information from a .bmp file into my program while dynamically allocating memory for all of it. So I defined the structures for the headers and for a pixel, and then I have to read each pixel into a multi-dimensional array of pixels. I am completely new to structures, and definitely new to pointers combined with structures. I will have to use a filter with the information later, but right now I just want to read everything in correctly. The array of pixels will be two-dimensional -- the width by the height of the image, I guess.
Here's my code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *inFile, *outFile;
typedef struct
[Code] ....
View 4 Replies
View Related
Jun 9, 2014
Why certain projects always roll their own data structures/utililiy classes rather than using the C++ standard libraries? such as linked lists and queues? Is there a particular reason for this?
View 11 Replies
View Related
Dec 1, 2014
I am working on my final project for my intro to c++. Its a simple program where you buy a car, choose parts for it, see the price of it in total, buying option, and to view past records.
So my problem lies with displaying the records. For some reason(doesn't many how many records there are) the very last record displays again without the "Model" part, but displays the rest of them fine. In other words, there are 2 problems, the last record is displayed twice, 2nd that added record displayed is missing the "model"(this problem doesn't matter really if you can solve the first problem, but would still like to know why it does that).
I tried debugging it and I believe the problem lies with the --------while(fName.good()). It just decides to repeat it again even though in the text file, it does not have that extra record.
//inventory
void viewInvent(string fName)
{
//variables
[Code]....
View 3 Replies
View Related
Aug 10, 2014
Below is a snippet of my code in which it loops through a file trying to find the matching record of a selection given by the user. I use tellg() to tell me where the search begins and it does in fact start at the beginning. But when the search actually executes, it starts at the last record, loops once, and ends, as it does not find the matching record (when the user enters '24' for example)
void Hardware::updateExistingRecord(ofstream &addRecordInfo, ifstream &updateRecord, Hardware &_records) {
//selection on which field to update
enum Field { RECORD_NUMBER = 1, TOOL_NAME, QUANTITY, COST, EXIT };
cout << "Enter record number you would like to update
";
cout << "Enter zero to exit
?";
[Code] ....
View 10 Replies
View Related
Jan 12, 2013
How To Delete A Record From binary File - C++ ?
View 1 Replies
View Related
Feb 17, 2013
Question: What is the efficiency and big O of the selection sort algorithm when the input happens to already be in nondecreasing order?
Answer: Not sure... since the input is in nondecreasing order, such that example 0, 1, 1, 2, 3, 4, 4, 5 then there will be no swap, Just comparisons of emelemts. So it is big O of n
View 2 Replies
View Related