C++ :: Displaying Address Of Character?

Feb 20, 2013

When this programs runs it displays odd symbols for the address of the character. This is only part of the program, I took out the parts that already work.

#include <iostream>
using namespace std;
char again;

[Code].....

View 2 Replies


ADVERTISEMENT

C++ :: Character Displaying From A String?

Jan 27, 2013

I want to input a string, say: abcdaa so, the program should output:

a
b
c
d

In other words, the program will display each character for only ONCE!!!! And display their frequency. Here is my idea: user will input a string and such string will be copied into another string variable called "checker".There will be a loop and each character will be printed, BUT, first, the program will check if the character to be printed is not equals to all elements of the checker string.

I already have the function to count the frequency of each character

GOAL: to make a program that will accept a string and use the HUFFMAN CODING to compress it.

for(x=0; x<string_in.size(); x++) {
cout<<" "<<string_in[x]<<endl;
for(y=0; y<string_in.size(); y++) {
if(checker[y]==string_in[x])
break;
else
checker[x]=string_in[x];
}
}

View 13 Replies View Related

C++ :: Converting Reference Address To Character String

Jun 15, 2014

I'm wanting to convert the reference address held by a pointer into a character string, combine the hexes into a single unsigned long int(using bitwise operators )so I can use the 32bits in conjunction with a separate algorithm to develop a more efficient, but less 'random', number, or should I say bit, generator that I'll be using in a Neural Network, with Genetic Algorithms used to modify the weights.

View 5 Replies View Related

C++ :: Debugging Code (Displaying Char String Per Character)

Jul 16, 2014

I've tried a bunch of alternative methods to prevent an assertion error. "not understanding" the bug and why I'm getting it are relevant here, not proper, (or more appropriate), coding methods. I would write it in another way to prevent the error, I simply want to understand what is happening during run-time that causes the situation.What is the bug?

---------------------------------------
[assertion error]
[expression _block_type_is_valid(phead->nBlockUse)]
--------------------------------

Code:
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "Enter your name : ";
string Name;

[code]...

View 1 Replies View Related

C++ :: Multi-character Character Constant Error Message?

Sep 14, 2014

I keep getting this warning message and I do not know how to fix it. Is it because I'm using char to instead of strings to replace all 't' with 'lp'?

#include<iostream>
#include<string>
#include <stdio.h>
using namespace std;
char * scanf(char * a) {

[code]....

View 6 Replies View Related

C++ :: Reading Data Character By Character From Text File

Jul 25, 2012

Double values are stored in text file. 23.5 36.8 34.2 ... My teacher told me to read them character by character and then make words, like i have to read "2" "3" "." "5" and now have to make it or treat it as word and then using atoi(). I have to convert it into double. but i dont know how to do this....

View 5 Replies View Related

C :: Read From Stdin (File) Character By Character

Nov 10, 2013

I have to optimize a code for below scenario. I am reading stdin (a file redirected to stdin) character by character. How many chars are going to come is not known. After every few chars there is a seaparator. e.g $ as below

rhhrkkj$hghjhdf$ddfkrjt

While reading, if the separator arrives I'm processing the string stored before that separator and then continue reading stdin in same fashion, till EOF. I am using getc(stdin) to read chars.

Using gprof I can see most of the program time is spent inside main() , for this reading logic. Rest of the program is just some insert and search operations. I am getting time of 0.01 secs at the moment, want to reduce further.

View 6 Replies View Related

C/C++ :: Read Input File Character By Character?

Aug 10, 2012

How do I write an a program that will read an input file character by character?

View 1 Replies View Related

C++ :: How To Read TXT File Character By Character

Oct 6, 2013

In my program, I'm supposed to read a text file (the name of which is given to me as a command line paramater, as long with an integer), and display the text in a specific format (each line can only be as long as the integer). However, I'm having trouble even reading the text file. I don't know the syntax. I'm only allowed to edit the function that does the formatting, and the code in that is

void typeset (int maxWidth, istream& documentIn)

I don't know how to 'read' the file, as most examples online are ifstream, or openFile or something like that. What I want to do is just read the first character of the file, and continuously keep reading characters until the end of the file.

View 10 Replies View Related

C/C++ :: Replacing Character In String With Another Character

Sep 13, 2014

So I'm trying to create a function that replaces any instance of a character in a string with another. So first I tried the replace() string member function:

In my implementation file

void NewString::ReplaceChar(const char& target,const char& entry)
{
this->replace(this->begin(),this->end(), target, entry);
};

Main program

#include "NewString.h"
using namespace ...;
int main()

[Code].....

Instead of replacing the the l's with y's it outputted a long string of y's. Also, NewString is derived from the string class (it's for the assignment). the header and whole implementation file, already tested.

I've also tried, instead, to use a for loop in ReplaceChar() but I need to overload the == operator and I don't know how I should exactly:

bool NewString::operator ==(const char& target)const {
if(*this == target)
return true;

[Code]....

I want the == operator to test if the value in the char array is equal to target but I'm not sure how to pass in the position. I'm guessing the this pointer in ReplaceChar() is not the same as the one dereferenced in ==() because target is never replaced by entry in the string.

View 5 Replies View Related

C :: Assignment Of Element Of 2D Character Array To 1D Character Array

Jul 4, 2014

Can we do this :

Code:
char strings[][100]={"ABC","EFG","IJK","LKM"};
char temp[100];
temp=strings[1];

View 3 Replies View Related

C++ :: Displaying Contents Of A Map

Jul 20, 2013

I'm trying to display the contents of this map. I'm having some trouble where the program ceasing to display after "Index Contents."(lines 33 -40) If I move the display for loop right where I'm inserting the values (line 52) into the map I get output. I'm not sure where bug is.

#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include <regex>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>

using namespace std;
typedef istream_iterator<string> isIterator;
typedef map<string, string> indexMap;

[Code] ....

View 1 Replies View Related

C/C++ :: Output Displaying As 0?

Mar 5, 2015

I am trying to write a c program to convert centimeters to inches and then to feet. I have most of the code written but not sure how to debug it. I keep getting "0" as all of my output.

#include <stdio.h>
// Main Function
int main(void)

[Code]....

View 2 Replies View Related

C++ :: Displaying 2D Array

Jan 6, 2012

I got assignment at my school to display 2D array like this:

This is default array:

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

Now I have to print the default array like this:

1 2 6 7
3 5 8 13
4 9 12 14
10 11 15 16

I have tried some codes to do it myself but i had no success.

View 1 Replies View Related

C++ :: Output Displaying Out Of The Screen

Feb 11, 2014

I have turbo c++ on windows xp SP2.....whenever i compile my code in turbo c++ i am getting output outside the screen.....but when i used code::block....i get the correct output...fits to screen ...

View 7 Replies View Related

C++ :: Displaying Image From Stream

Feb 24, 2013

I'm trying to display an image from a stream data. But there is no image when getting image::from stream.

It's my source code:

Code:
IStream* pstream = NULL;
if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pstream))) {
ULONG lreal = 0;
pstream->Write(chIncomingDataBuffer, iEnd, &lreal );

[Code]...

There is no image from data.

View 5 Replies View Related

C :: Displaying Proper Value With Arrays?

Jun 30, 2014

I'm currently working on a temperature conversion program using arrays / pointers as practice.

I will post the code below, its quite a bit lengthy and its also incomplete. Everything was going smoothly and I continually test my code as I write to completion, then I ran into a small road block.

My problem here is regarding the output from the first if statement in main. When I enter a value to convert from F to C. It successfully converts the first value I enter, but any other value after the first one during the loop in the first if statement, just shows long numbers of all sorts.

The output looks like this:

I kept checking the logic behind what I did, and for me it seems to be correct. Here is the code:

Code:

#include <stdio.h>
#define array_size 5
#define NEWLINE printf("
")

[Code].....

View 4 Replies View Related

C++ :: Merging Two Arrays And Displaying Them Together In End

Oct 7, 2014

merging two arrays together and displaying them together in the end. However, I do not know how to start the merge function.

#include <iostream>
#include <assert.h>
using namespace std;
struct Array {
int* array; // point to the dynamically allocated array
}

[code]....

View 1 Replies View Related

C++ :: Displaying Inverted Pyramid

Oct 7, 2013

The user will enter the number of '*'s on the 1st row (ntop) and then the number of rows forming the trapezoid (nrows). (using <iostream>, cout)

For instance, an inverted trapezoid with 7 '*"s in the 1st row and 3 rows forming the inverted trapezoid looks like:

for (i = nrows; i >= 1; i--) {
for (j = 0; j >= nrows; j++) {
cout << " ";
} for (k=ntop; k >= 2; k--) {
cout << "*";
} }

The output is just blank as of now.

View 3 Replies View Related

C++ :: Displaying Most Profitable Day Of Week

May 9, 2014

I am trying write a void function which will tally up the totals for each day and then display the most profitable day of the week.

#include "stdafx.h"
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <fstream>
struct Menu_Items {
string Item;
double Price;

[Code] .....

The void function must pass as a parameter a pointer to the first element of the Orders_Placed array. I have attempted to write this. But I do not think I am even close. I need to have 7 double variables that hold the totals for each day of the week. Those are the MonTotals , TueTotals , etc....

How do I get these totals for each day?

How do I fix this void function so that is displays the most profitable day. Also, would the function call be Biggest_Profit(Orders_Placed)??

The GetPrice function provides the price given a menu item.

View 1 Replies View Related

C++ :: Displaying Commas In Loop?

Oct 6, 2013

If the number 4 is entered, the output should be the following:

1: 1
2: 1, 2
3: 1, 3
4: 1, 2, 4,

My output, however, is different but I know its an error with the comma.f

1: 1, , ,
2: 1, 2, ,
3: 1, , 3,
4: 1, 2, , 4

Here is my code:

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

[Code].....

View 1 Replies View Related

C++ :: Displaying Averages In A Table

Feb 14, 2013

I've finally been able to get my coding corrected after doing this for 5 hours and watching numerous tutorials on it... But I now need to create a table. how to create a table with dashed lines like -----------------, both vertical and horizontal.

Another issue I have is that I'm having trouble trying to get a prompt to ask the user how many programs, tests, and quizzes he/she completed with their total points. I got the basic programming done, but need a prompt asking "How many (quizzes, tests, or programs) have you completed?"

Finally, the do-while loop is driving me insane, where I have to set certain values. If it is greater than 2, then I insert formula 1, but if it is less than 2, then I insert formula 2. Whichever way it goes, the total points earned minus the two lowest scores are then calculated into an average.

Code:

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()

[code]....

The whole basis of the program is to calculate the averages of programs, tests, and quizzes done during a semester at a school. The user is asked how many of each category he/she has completed (total points earned and total points possible). All of this is then calculated into a cumulative class average in a table along with points earned and points possible for each category (along with tests and quizzes combined into one average along with individual averages).

View 2 Replies View Related

C++ :: Why Is Structure Member Not Displaying

Jan 7, 2015

I have started working with structures so here's a side project from my text book. It's purpose is fairly simple; it asks for the sales of each quarter of the year from 4 different divisions and then calculates the average quarterly sales and total annual sales and finally displays all the data. My problem is that in the function "displayCompanyInfo" the statement

std::cout << "Division " << R.division_name << std::endl;
does not display the name of the division. With that in mind here is the code:
#include <iostream>
#include <string>
struct CompanyInfo
{

[Code]....

As you can see the last part of the output has statements that say "Division" however they do not say the name of the division afterwards. I don't understand why that is?

View 2 Replies View Related

C++ :: Getline Is Not Displaying In One Line

Feb 16, 2014

I used getline to import EMPLOYEE's First and Last Name from a txt file. After calculating the weights ans stuff. Now when i try to write to output txt file am having the below issue in which its not putting it in one line.

***CODE***
fout << "Note: This report for " << employee << " was prepared according to the fair practice of the University." << endl ;

***THIS IS WHAT ITS PRINTING***
Note: This report for FIRSTNAME LASTNAME was prepared according to the fair practice of the University.

I also tried like this;

***CODE***
fout << "Note: This report for " << getline(fin, employee) <<" was prepared according to the fair practice of the University." << endl ;

***THIS IS WHAT ITS PRINTING***
Note: This report for 0 was prepared according to the fair practice of the University.

this second code puts everything in one line but its showing 0 (zero) instead of the employee's first and last name.

View 4 Replies View Related

C++ :: Not Displaying Tree Elements

Apr 4, 2014

Not Displaying tree elements. Here is the code. Want to know the error.

#include <iostream>
struct TreeNode
{
int number;
TreeNode* left;
TreeNode* right;
};
struct Tree

[Code]...

View 1 Replies View Related

C++ :: How To Stop Displaying The Console

Mar 6, 2013

I am trying to display a messagebox, but instead of just displaying the message box, there is also a console the pops up. How do I prevent the console from popping up? I'm using Visual Studio 2012. I'm creating an empty project, but I still get the console.

View 1 Replies View Related







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