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


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 :: Debugging A Code On Linux OS

Apr 11, 2013

I have a code that I'd like to debugg it.

Question
1 - What is the correct command line to use the debugger ?
2 - Do I need to install additional software for the debugger ?

if yes what it's name?

I use ububtu 12.4compiling command: gcc abc.c -lpthread -o abc

View 3 Replies View Related

C# :: Code Was Skipped While Debugging For No Reason

Oct 6, 2014

I have something like this

string rid = row.Cells[0].Value.ToString();
string identification = row.Cells[9].Value.ToString();
IDLabel.Text = "ID: " + rid + " <Identification: " + identification + ">";

I checked that while identification has a value, the IDLabel.Text was run just fine, but if identification has null value, IDLabel.Text was skipped totally...

View 13 Replies View Related

C++ :: Debugging Char Variable

Oct 13, 2014

I have a bug and when I debugged in some point i needed to know whats inside my char **grid , when i hold mouse over this variable in debug mode i can only see hex or address.. ! i cant see my values grid is 10 * 10 table which hold a number from 1 to 3 .... is there any way for me to see whats inside ?

I'm using visual studio 2013 ultimate ....

View 2 Replies View Related

C++ :: Compare Element Of Char Array And String With Single Character

Dec 3, 2014

how can i compare an element of the char array and string with single chsracter also how to compare char array to cpp string

View 3 Replies View Related

C++ :: Code Only Prints Out First Char Of Each String

Feb 27, 2012

I have the following code that prints out only the first char of each string. Why does it not print out the entire unsgined char* ?

Code:
#include <iostream>
#include <vector>
using namespace std;
void PrintVector(vector<unsigned char*>& data) {
for(size_t i = 0; i < data.size(); i++)

[Code] .....

View 5 Replies View Related

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 View Related

C++ :: Code For Displaying Text File Not Working

Dec 6, 2013

i have turbo c++ 3.0 installed . my program is compiled without error and is running. but when i choose option to display scores in the consol , it hangs . check my code. i have to run this on same compiler. i just want to display all the contenets of text file .

#include<iostream.h>
#include<conio.h>
#include<stdio.h>

[Code].....

View 4 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 :: Copy Every Single Character From One Char Into Another

Jun 5, 2013

I have some problems with copying a single character from one char into another. How do I do that? Here is the function I am using

Code:

void
text_col (char line[]) {
char line1[1];
int l, ii;
l = strlen(line);

[Code] ....

I am trying to copy in a loop every single character from char line into char line1. That is not working.

View 8 Replies View Related

C :: Setting Character In Malloc Char Array

Oct 16, 2013

I am attempting to change a character in a character array.In the code below, there are three attempts to do this. Only the first one will succeed. The last two both segfaults. If I understand correctly, str_one is declared in the heap, and could therefore be manipulated; and in contrast, str_two is declared in the stack and is therefore immutable, thus the segfault, when update it is attempted. However, I understand that using malloc, one is able to assign a pointer and allocate space in heap memory. Thus, I should be able to manipulate the assigned variable str_three. Doing so, however, results in a segfault.

Code:

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char const* argv[])
{
char str_one[4092] = "This is string number one";
char * str_two = "This is string number two";

[Code]...

View 2 Replies View Related

Visual C++ :: Prompt User To Enter Integer Value And Character Code To Indicate Conversion

Sep 14, 2013

I'm expected to write a c program for this question :

Using these header files
#include <stdio.h>
#include <conio.h>

Question : Write a program that will prompt the user to enter an integer value and a character code to indicate whether they want to do a Kilogram to Pounds conversion (A) or a Pounds to Kilogram (B) conversion. Note that 1 kg = 2.2 pounds. The program should then do the necessary conversion indicated by the code and display the newly converted value to the screen.

View 1 Replies View Related

C++ :: Finding And Displaying A Word From A String?

Mar 2, 2014

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
//Program Goal
//Have 3 Strings to represent 3 categories
//Have the user type in their name
//Have the user type in a full sentence how they are feeling
//Program should find the word in the user inputted sentence and display an appropriate response

[Code]...

View 4 Replies View Related

C :: Trying To Scanf A Char And Code Just Jump Over It

Jan 25, 2014

I'm doing a code to calculate the final grade of students. This is a work for college, and I need to keep this structure.

My problem is that last scanf, it is ignored when I compile the code. It "works" if I try to scan a string, float or int.

Code:

#include <stdio.h>
#include <stdlib.h>
void nfinal(float NOTA1,float NOTA2,float NOTA3,char MEDIA){
int NOTA;
if(MEDIA=='A'){
NOTA=(NOTA1+NOTA2+NOTA3)/3;

[Code]....

View 3 Replies View Related

C :: Displaying A String Loaded From A Text File

Jan 19, 2014

I'm working on a program that can load all words from a dictionary "English2.txt" (it's attached to the post), then put every word into a 2-dimensional matrix (every line is reserved for one word) and display them. After loading every word into a matrix, when I try to display first 8 words with printf, I can't do it without '' at the end of a line. Otherwise only the 8th word is displayed... What's more, when I try to read the length of the first word with strlen, it says, that it has 4 characters (in fact there are only 3 and it's the word "AAA"). What could be the reason for that?

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
int main()
{
FILE *fp;
char buffer[32];

[Code]...

View 4 Replies View Related

C++ :: Increase Char Code Doesn't Work

Jun 11, 2014

Code:

#include <iostream>
using namespace std;
int main () {
char character = 'a';

[Code] .....

the point of this code is to increase character by 1 (so from a to b in this case).

The line highligted in red is the line that the system is rejecting at the moment (but there may be other issues). why it is invalid?

View 5 Replies View Related

C++ :: Translate Char Array From (Russian Code) To Unicode?

Feb 10, 2012

How translate char array from "MS-DOS Codepage 866" (Russian code) to Unicode?

View 3 Replies View Related

C# :: How To Get Int Value Of Each Character In A String And Then Add Them All Together

Aug 20, 2012

I'm trying to get the int value of each character in a string and then add them all together so I can do a 1's complement of the total value. I'm trying to do simple checkum kinda of thing for verification of data.

For example: string DPacket = "Hello World!";

I would like to have each character added and do the ones complement. Will it be easier to convert first to int and then add or any other easier way? So my result should be the decimal value addition of each character and then do the ones complement to that.

View 5 Replies View Related

C++ :: String Character Removal

Dec 25, 2013

I know how to remove certain characters from a string by using something like this:

Code: string str ("Hello world!");
erase (0, 6);

That's great if I want to do that manually, but say if someone entered a string, how would I automatically remove every other character they entered?

View 4 Replies View Related

C :: Check Certain Character Is In String Or Not?

Mar 6, 2015

I want to check whether a certain character is in a string or not but my code is not working

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

[Code].....

View 7 Replies View Related

C :: Insert Character To A String

Feb 26, 2013

Let's say i have a string "file.txt" and i want to insert "_out" to make it look like "file_out.txt"

I don't know how to do this ....

View 8 Replies View Related

C :: Copy A Character To String

Mar 6, 2015

Copy some characters from char * arg to char * first using a loop with specific conditions.

Code:

char * arg;
// set arg some string...
char first_[25];
char * first;
int length;
length=strlen(arg);
for (n++; arg[n] != '}' || n>=length-1; n++)
strcpy(first,arg[n]); // first += arg[n]; I have strcpy(first,arg[n]); but arg[n] is char and strcpy expects char * ;

how to solve this?

View 2 Replies View Related

C :: Display One Character In A String?

Jun 14, 2013

It's been about two years since I last program c, now I need to do it for a basic project. How would I print out one letter in a string?

For example lets say I have a string called str=[Hello]. I want to display the third letter so just the "l". Here's what I have so far:

Code:

#include<stdio.h>
int main() {
char str[50] = "Hello";
printf("The third letter is : %s
",str[3]);
return 0;
}

View 2 Replies View Related

C++ :: Searching For Character In String

Jun 19, 2013

I'm trying to find a < character in a document, get it's position. Then find > and get it's position. Then i want to delete all things between that but runtime is terminating my process so i don't know what to do.

The code:

#include <iostream>
#include <conio.h>
#include <stdio.h>

[Code].....

View 6 Replies View Related

C# :: How To Replace Character In String

Feb 12, 2015

I have an open file dialog that opend the xml file and store the path to the textbox, it returns the path correctly but when i need to store that xml file into the database it tells me that there is an error next to '' because when i try to debug it it gives me "C:\Student Results\FC2015.xml" this results then it breaks. here is my code:

This code returns xml path to textbox

OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "XML Files (*.xml)|*.xml";
ofd.FilterIndex = 0;

[Code]....

View 2 Replies View Related







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