C/C++ :: Converting BMP To Strings Of 0 And 1 (Binary Format)

Mar 14, 2014

I want to read a Bitmap file in C language and produce the binary equivalent of it in the form of 0's and 1's.

View 1 Replies


ADVERTISEMENT

C++ :: Converting One Format To Another?

Apr 7, 2013

I am in a c++ class and my group is having a hard time making this work... It keeps saying that 'fileOne.open' isn't working.

#include <iostream>
#include <string>
#include <fstream>

[Code]....

View 3 Replies View Related

C :: Reading And Printing In A Specific Format Strings Of Characters And Integers

Feb 23, 2015

I have been skimming and searching but dont know how to word the search just right to find what I need to know. I have written simple stuff with the support of tutorials like weight conversion or loops counting up to a set number. Nothing amazing. The other day I found out how to input and print a string rather than a single text character which i though was bad ass. I even got it to read multiple strings on a single line and found a way to read multiple lines. I can even format it to read both integers and characters on the same line as long as I know the predefined format.

On to my question... How do I read multiple lines with both carecters and integers. for instance:

nissan 1996
toyota 1998
or more comples like
nissan gtr 1996
toyota markii 1998

I want to use
int year;
char make[10]; maybe need to use char make[10][10]; for an array i would guess.
char model[10]; optional for the extra data

but reproduce what i read in a different order. say...
1996 nissan
1998 toyota
vice the original format.

this is what I have tried.

Code: scanf("%s %s", &make,&year);

//The way I seen to read multiple lines was on here

scanf("%[^/t]", %make);

But this wont let me separate the two into two differnet definded data types. Let alone use printf to display them in reverse order.

View 1 Replies View Related

C++ :: Cannot Write As Binary Using Dat Format In Ubuntu

Nov 29, 2014

I cannot write as binary using .dat format in ubuntu, why?

View 5 Replies View Related

C/C++ :: Custom Binary File Format

Jul 9, 2014

Development of a custom binary file type? So far all I know is the just the basic structures of the binary file type, I know that structures are involved but the implementation part I have run into walls.

View 1 Replies View Related

C++ :: Writing In Binary Format Array Of Unsigned Int Values

Aug 5, 2013

I am trying to write down in binary format an array of unsigned int values but i get the following compilation error :

: In function ‘int CIndex(std::fstream&, std::fstream&, std::fstream&, std::fstream&)’:
./src/IndexBuilder/index.cpp:23:26: error: no matching function for call to ‘std::basic_fstream<char>::write(int*, long unsigned int)’
./src/IndexBuilder/index.cpp:23:26: note: candidate is:
/usr/include/c++/4.6/bits/ostream.tcc:184:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::write(const _CharT*, std::streamsize) [with _CharT = char, _Traits = std::char_traits<char>, std::streamsize = long int]

This is the part the is not working:

Code:
// uia is : unsigned int * uia;
// then I have allocated the space for it
// load it with unsigned int's
// k is the number of variables in my array

o.write(uia,sizeof(unsigned int)*k); But thsi should be so simple and strait forward.... in c i do it as :

Code:
fwrite(uia, sizeof(unsigned int), k , fp); but since i would need to convert fstream to FILE* i decided to do it c++ way.

and this is how i opened the file :

Code:
o.open (fileName.c_str(),std::ios::out|std::ios::binary);

View 5 Replies View Related

C/C++ :: Error / The Specified File Is Unrecognized Or Unsupported Binary Format

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

C++ :: Converting Strings In Application

Jun 8, 2014

I am having trouble converting strings in my application.

This is the code that is eventually getting called, the first parameter takes a LPCWSTR

Code:
hr = m_pGraph->RenderFile(m_filePath, NULL); // takes LPCWSTR This is where the trouble begins.

The compiler shows that sResult is proper but after I try to convert a std::string to a wchar it prints garbage

Code: const wchar_t* m_filePath = (wchar_t *) oDb->GetNext().c_str();

Code:
std::string CSqlLiteDatabase::GetNext() {
sqlite3_stmt *oStmt = nullptr;
std::string sql = "SELECT path || filename FROM table WHERE id = 1";
char message[255];

[Code] ....

View 6 Replies View Related

C++ :: Converting Strings To Dates

Feb 8, 2014

Code for converting strings to Dates in C++.

Example: What is the date:
User response: 12/05/14

Any way I can code this to recognize it as a date, and make it so that the date is sortable? Not referring to the system date, but a user input date.

View 1 Replies View Related

C/C++ :: Display Contents Of Binary Tree In Per-level Format - Undefined Reference

Oct 5, 2014

I am coding in C++ an implementation of BTree Insertion. I want to display the contents of the Tree in a per-level format. After writing functions and trying to run. I get the error Undefined reference.

// C++ program for B-Tree insertion
#include<iostream>
using namespace std;

// A BTree node
class BTreeNode{
int *keys; // An array of keys
int order; // Minimum degree (defines the range for number of keys)
BTreeNode **child; // An array of child pointers
int size; // Current number of keys

[Code] .....

View 6 Replies View Related

C :: Converting Strings In File To Lowercase / Uppercase?

Aug 4, 2013

okay so this program is basically getting the files from user input then reading the original file and convert the string into a uppercase/lowercase form and save it into another file. Is there a way to save the string from the first file to a variable then convertin the string in the variable and copy that onto the new file? So far i have

Code:

#include <stdio.h>
#include <string.h>
int main() {

[Code].....

View 1 Replies View Related

C++ :: Converting Multiple Lines Of Strings To Double

Aug 26, 2014

I am trying to convert multiple lines of strings to double with std::stod .... I used the code found on the website:

#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
int main() {
std::string two_doubles =" 22145.365 -3564789";
std::string::size_type K;
double first = std::stod (two_doubles, &K);
double second = std::stod (two_doubles.substr(K));
}

The string starts with white spaces. I get this error message when compiling:

warning unused variable 'first'
warning unused variable 'second'

How do you convert the two numbers in the string two_doubles to doubles?

View 2 Replies View Related

C :: Converting Two Strings To Upper And Lower Case Using Function

Dec 6, 2014

My code so far

Code:

#include <stdio.h>
#include <ctype.h>
#include <string.h>

[Code]....

I keep getting these 3 errors :

error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '{' at end of input|.

View 4 Replies View Related

C++ :: Converting Decimals To Binary

Apr 28, 2013

I have written a code but i tried to alter it a little in this manner. But it seemed to not recognise what hexStack.getsize() > 0) is..??

while(hexStack.getSize() > 0)
{
//buffer being a previously declared int
buffer = hexStack.pop();

[Code]....

View 6 Replies View Related

C++ :: Converting Binary Digits To Hex?

Apr 16, 2013

converting 8bit binary into 2 digit hex

how to do this?

im starting it now but going in the direction of using arrays

View 4 Replies View Related

C :: Converting Binary Data In A Txt File Into HEX

Apr 17, 2013

I'm not the best at C but I'm trying to write a C function that basically opens a text file with assembler language does a syntax error check on it and then converts the binary data into hex.

This is my code so far:

Code:

#include <stdio.h>
#include <string.h>
int main(void)
{
FILE*fname;
char prompt;
char filename[15];
char text[100];
printf( "Please enter the name of the file you wish to open: " );

[Code]...

View 6 Replies View Related

C++ :: Converting Decimal To Binary Using Recursion

Feb 25, 2013

I'm trying to write a program that converts a decimal number to a binary one. I have most of the program written, but I am having a little bit of trouble. Whenever I enter a decimal number, the program will convert it correctly to binary, however, the last number is not included in the conversion. EX: Converting 37 into binary (0100101) yields 010010 when entered into the program. BTW the program must utilize recursion to achieve this goal.

#include <iostream>
using namespace std;
void decToBinary(int num1);
int main() {
int num1;

[code]....

View 4 Replies View Related

C++ :: Converting Binary Numbers Into Decimal

Apr 25, 2014

This is the question: [URL] .....

Now I have the binary numbers printed out in my code, but I don't know how I can covert them into to decimal.

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int main() {
int numberOfDigits;
int numberOfRows;
char flag;

[Code] ....

View 1 Replies View Related

C++ :: Check Parameters Of Binary String Before Converting To Dec Values

Feb 9, 2015

I'm fairly new to C++ and programming in general and I'm trying to get a program to check the parameters of a binary string before converting that string to dec values. I have the user input 'num' line 39 - 42, but I want to reuse that same value in the 'void bin_to_dec()' function. Is there anyway I can use the same variable between void functions?

13 #include <bitset>
14 #include <sstream>
15 using namespace std;
16
17 void dec_to_bin(){
18 string mess;

[Code] ....

View 3 Replies View Related

C/C++ :: Converting Two Digit Hexadecimal Number To Binary Representation

Jan 25, 2014

The program is supposed to convert a two digit hexadecimal number to its binary representation. My code runs without any problems but I do not know how to limit the user's input to two digits only. For example the person can input "1ABC" and the program will give the binary representation and I need it to only accept two digit only like for example "1A".

#include<stdio.h>
#define MAX 1000
int main(){
char binaryNumber[MAX],hexaDecimal[MAX];
long int i=0;
printf("Enter a two digit hexadecimal number: ");

[Code] ....

View 8 Replies View Related

C/C++ :: Converting Number Into Binary Or Hexadecimal Or Octal Using Arrays

Mar 1, 2013

Write a program in c++ to accept a number and convert this number into binary or hexa decimal or octal number according to the user choice using the concept of array.

View 6 Replies View Related

Visual C++ :: Converting Decimal Number Given By User To Binary?

Dec 19, 2014

Write a C++ program that adds three binary numbers of 8-bit each. Every number is stored into an array of 8 elements.

Example:

Array A
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0
+
Array B
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0
+
Array C
0 1 2 3 4 5 6 7
0 1 1 0 1 1 1 0

Store the result into an array D of 8 elements. Your program should show the decimal numbers for every binary number. Print screen of 6 answers. This means you should try your program six times with different numbers in every run and show the printed screen result.

View 5 Replies View Related

C++ :: Print Hexadecimal Strings From Binary

Aug 19, 2013

How to search in C or C++ a hexadecimal patterns within a binary file.

For example:

String1:

Code: 0x44 0x65 0x07

Then, once found, extract those 3 bytes and the next 11 bytes (14 bytes in total).

Finally, from those 14 bytes, print without spaces "bytes 1 to 6", "bytes 6 to 12", and byte "13 to 14".

Then I would like to print last 2 bytes (13 to 14) joined in decimal format.

The output without any conversion would be:

Code:
446507c90688 888000800005 0015
4465072ec918 059173495269 002C
44650700cc01 01811bc90b00 00AB

But the output converting to decimal the last 2 bytes would be:

Code:
446507c90688 888000800005 21
4465072ec918 059173495269 44
44650700cc01 01811bc90b00 171

The sample file is attached, and looks like this:

Code:

06 00 00 80 00 00 00 80 09 3c c9 06 88 88 80 00
80 00 44 65 07 c9 06 88 88 80 00 80 00 05 00 15
37 06 01 00 00 01 00 65 00 00 00 02 00 00 02 00
18 00 00 00 03 00 00 03 00 17 00 00 00 04 00 00

[Code] .....

View 8 Replies View Related

Visual C++ :: How To Do Binary Search On A Vector Of Strings

Sep 25, 2012

I'm trying to do a binary search on a vector of strings and keep getting this error. This is the PhoneEntry header file with the class declaration:

Code:
using namespace std;
#include<string>
#include<iostream>
#include<fstream>
#include<vector>
#include"phoneNumber.h"

[Code] .....

View 5 Replies View Related

C++ :: How To Append Strings To The Front Of Other Strings

Apr 7, 2013

I am programming a translator, and I have it so that it detects words with spaces both in front of and behind them, so I did "string.append(space);" where space equals " ". That added a space to the end, but I still need a space added to the front.

View 1 Replies View Related

C/C++ :: Print More Strings (the Strings May Contain Spaces)?

Feb 12, 2014

I have a problem who must print the sentences who have lenght more than 20 characters. I dont know why, but it prints just the first words. Look what i made.

#include<stdio.h>
#include<conio.h>  
int main()

[Code]....

For instance :

Give the number of sentences : 3

First sentence : I like the website bytes.com
Second sentence : I like more the website bytes.com
Third sentence : bytes.com

After I compile the program it should print the first two sentences.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved