C++ :: Error With Binary IO
Jan 6, 2015
I am trying to make a program like a virtual machine, and therefore I need to have a virtual hard drive. I have it split across four files, each being exactly 67,108,864 bytes (at this point, the files consist of 0x00 throughout the entire file). When I try to write to the beginning of one of the files, I get a "EXC_BAD_ACCESS (code=1, address=0xff)" from Xcode.
Here is my source code.
Code: #include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream drive1("main1.vhd", ios::in | ios::out | ios::binary);
fstream drive2("main2.vhd", ios::in | ios::out | ios::binary);
fstream drive3("main3.vhd", ios::in | ios::out | ios::binary);
fstream drive4("main4.vhd", ios::in | ios::out | ios::binary);
[code]....
View 4 Replies
ADVERTISEMENT
Aug 24, 2014
I am trying to convert user inputted decimal to binary .
Code:
#include<stdio.h>
main() {
int a,b,c,d[30],i,j,e[30];
[Code].....
View 2 Replies
View Related
Mar 8, 2013
I wrote a binary function based on existing template:
template <class T> struct percentage : binary_function <T,T,double> {
double operator() (const T& x, const T& y) const
{return x*1.0/(x+y);}
};
I call it in form of percentage<int>() When I compile, it's indicated: error C2143: syntax error : missing ',' before '<' I use VC 2012.
View 5 Replies
View Related
May 20, 2013
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.
#include <iostream>
#include <conio.h>
#include <fstream>
struct abc {
char name[100];
int age;
[Code] .....
View 3 Replies
View Related
Mar 17, 2014
I am getting a weird error "The specified file is an unrecognized or unsupported binary format"
I have this >
#include <iostream>
#include "calculator.h"
using namespace std;
int calculator::getDisplay() {
return display;
} void calculator::enter(int nu
[code]......
View 6 Replies
View Related
Mar 14, 2013
Objective of this program is to read binary data from a file and print it.
Code:
#include <stdio.h>
void readFile(void);
int main(){
readFile();
return 0;
[Code] .....
But When I Run This Code First It Print "Error." Then Rest Of The File.Say In My File I Have "I AM HUMAN", It Prints "Error. HUMAN"!!
I Cant Figure Out Whats Wrong In The readFile() Function.It seems right to me.
View 4 Replies
View Related
Mar 26, 2013
I am trying to implement the insert function of a binary tree. Atm when I try and insert 3 nodes, the program breaks and gives me a stack overflow error. The error points to a getter function for an identifier for the data in my node class.
void LinkedList::add(Product *myProduct) {
if (_length==0) {
_head = new Node(NULL, NULL, myProduct);
_end = _head;
_length=1;
[Code] ....
Here is my insert function, the error message is
"An unhandled exception of type 'System.NullReferenceException' occurred in SDI2.exe
Additional information: Object reference not set to an instance of an object. "
In my main I have declared an instance of product, "productToAdd = new Product(id,idPrice);" so I'm a bit confused as to what I need to include..
View 3 Replies
View Related
Mar 21, 2014
I'm writing a binary search tree program and I got it to compile but as soon as I input something it returns a "segmentation fault error" . I suspect the issue with the code is withing my `add` function.
template<typename T>
void BinarySearchTree<T>::add(T value) {
if (m_root == nullptr) {
Node<T>* node = new Node<T>;
node->setValue(value);
m_root = node;
[Code] ....
View 6 Replies
View Related
Aug 1, 2013
#include<iostream.h>
#include<conio.h>
class sum {
int a,b,ans;
public:
void geta() {
cin>>a;
[Code] ....
View 1 Replies
View Related
Apr 2, 2013
This is the first time I have encountered a "no stack." error giving me a seg fault. Anyhow, I am scanning words into a binary search tree and it is giving me a seg fault.
Here is the file (words.txt):
4
bravo
alpha
gamma
delta
Code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct node_t{
char *word;
struct node_t *left;
struct node_t *right;
[Code] .....
View 5 Replies
View Related
Dec 6, 2013
Following is the program I wrote it basically takes 9 inputs and then save them into binary file. then print out the data stored in binary data and find inverse of it then print the inverse out. but its stuck in a loop somewhere.
Code:
#include <stdio.h>
int main() {
int a[3][3],i,j;
float determinant=0;
int x;
FILE *fp = fopen ("file.bin", "wb");
[Code] .....
View 6 Replies
View Related
Sep 8, 2014
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;
[code]....
View 1 Replies
View Related
Apr 3, 2013
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);
[code].....
Errors:
Code:
1>d:c++consoleapplicationconsoleapplicationinventoryitem.h(6): error C2061: syntax error : identifier 'string'
1>d:c++consoleapplicationconsoleapplicationinventoryitem.h(8): error C2146: syntax error : missing ';' before identifier 'getName'
[Code] .....
View 14 Replies
View Related
Oct 5, 2013
My assignment is to write a binary calculator that works with floating point for simple math (+,-,x,/). How to do this. the binary numbers need to be from the user.
View 2 Replies
View Related
Feb 1, 2014
It only prints out the root in an infinite loop.
Code: void Btree::printTree(Node* tree)
{
tree=root;
if (tree != NULL)
{
std::cout<<" "<< tree->key;
printTree(tree->left);
printTree(tree->right);
}
}
View 5 Replies
View Related
Nov 24, 2014
When reading a binary .img why is it when you read it by slurping in the file, then save it to a string and cout, you don't see the binary but random garbage?
View 11 Replies
View Related
Aug 12, 2014
It has been a while since I built a binary tree from scratch so I decided to do it. Everything works fine but this one function. When I enter a number to search it just keeps running and allowing me to keep enter numbers.
Code:
void tree::search(int key,Node* leaf) {
if (leaf == NULL) {
std::cout<<"The tree is empty
[Code] ......
View 3 Replies
View Related
Jan 1, 2015
Error message:Invalids operands to binary * (have 'double(*)(double, double)' and 'double)
Red words is the error, but I unable to figure out any solution:
Code:
/* Computes the weight of a batch of flat washers*/
#include <stdio.h>
#include <conio.h>
#define PI 3.14159
/* Funtion prototype */
double find_area(double a, double b, double c, double d, int e);
[Code] ......
View 4 Replies
View Related
Jul 19, 2013
I have an int array with the binary value of a char. How to to turn it into a char? I can transform it to an int but then I'm stuck.
Code:
#include <stdio.h>
int main() {
int a[260] = {0,1,1,0,0,0,0,1};
char buf[260];
int b=0;
for(int i=0; i<8; i++) {
b=10*b+a[i];
}
itoa(b, buf, 10);
View 6 Replies
View Related
Aug 25, 2014
I am using windows 64 bit 2007 , codeblocks and ive tried googling on how to strip all symbols to binary so that the people i send it to cannot read the game files but ive not found anything much... How do i do it on codeblocks..? Code:
View 4 Replies
View Related
Mar 30, 2014
I am very new to programming and have been working on a program that can receive decimals or binary numbers and convert them. The decimal --> binary works fine. For some reason I cannot figure out I cannot get the "BinaryToDecimal" function to perform. By putting a "printf" into the for-loop.
Code:
#include <stdio.h>#include <string.h>
#include <math.h>
char* ReverseString (char _result[]) {
int start, end, length = strlen(_result);
char swap;
for (start = 0, end = length-1; start < end; start++, end--)
[code]....
View 2 Replies
View Related
Jan 25, 2013
I am getting this error in lines that involve "ch[_]" in lines 27, 28, 29, 33, 42, 43, 44, and 48, heres the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
struct integer{
int* digits;
int size;
[Code] ....
View 7 Replies
View Related
May 28, 2013
I have a problem with the C code . I created two functions, one that runs through the tree inorder, the other that returns the maximum value in the tree. The problem is when I use in the main the method "max", which goes in a loop and not print anything on the screen . If I remove the call to method "max" it works fine. Here's the code:
Code:
#include<stdio.h>
#include<stdlib.h>
#define bool int
/* A binary tree tNode has data, pointer to left child
and a pointer to right child */
struct tNode {
[Code]...
View 13 Replies
View Related
Nov 15, 2013
How to do this program i can easily do it in a simple for loop but i have to do this program with the following directions:
1. Write a function called bitN() that returns the value of bit N in number, where number is the first parameter, and N is the second. Assume N of the least significant bit is zero and that both parameters are unsigned int's. (A simple one-liner will suffice)
2. Write a main() function that uses bitN() to convert a decimal integer into its binary equivalent. Obtain the integer to convert from the first command-line argument.
3. Use the expression
unsigned int numBits = sizeof(unsigned int)*CHAR_BIT;
to get the number of bits in an unsigned int. (Include limits.h to get the definition for CHAR_BIT.)
View 2 Replies
View Related
Feb 26, 2013
I'm trying to make a program that takes up to a seven digit binary number and converts it to its decimal equivalent. I'm still a beginner, so this might be a simple question but how do I stop the user from entering anything but 1s and 0s? This means no decimals or numbers other than 1 or 0.I already made it so it won't accept anything below 0 or above 1111111.
View 1 Replies
View Related
Apr 3, 2013
I am using c to read and write contents of a file into other:
FILE *ptr;
status_t status;
uint32_t block_size, result;
uint32_t num_blocks;
char temp_buffer[1024];
}
[code]....
Is there way to see the binary content of this file.
View 2 Replies
View Related