C :: Detect Frequency Of Printable Characters - Incorrect Outcome

Mar 10, 2013

We have to make a code to detect the frequency of printable characters. But when I run the code, sometimes it can't detect the Uppercase Letters. But it can sometimes. It's a bit buggy, and it really can't get the frequency of the space character.

Does textcolor affect the outcome?

Code:
#include<stdio.h>#include<conio.h>
int main ()
{
clrscr();
char name[40],sentence[1000],ch;
int c=0,count[95]={0};
textcolor(LIGHTCYAN);

[Code] ....

I also noticed that it stops detecting the frequency when there is a space between character/s.

View 3 Replies


ADVERTISEMENT

C/C++ :: Program To Read In And Count All Printable Characters (ASCII 32-126)

Feb 12, 2014

I'm writing a program that reads and counts all the printable characters (ASCII 32-126)found in a text file.

For example if the text file read: Why so serious?

The output to the screen would display(in order of ascii value however):

Character-----Total
W--------------1
h--------------1
y--------------1
s--------------3
o--------------2
etc...

However, I don't think it's reading any of the characters.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <string>
using namespace std;
int main() {
int i, count[127];

[Code] .....

View 2 Replies View Related

C/C++ :: Finding Highest Frequency From Array Of Characters

Jan 27, 2015

I have been working on a project that deals with an array of characters and finding there frequencies. I was able to determine the frequencies that where greater than 1, but I need to find the HIGHEST frequency.

Here is my full code:

#include <iostream>
using namespace std;
void input(char unlisted[80], int& n);
void bubblesort(char unlisted[80], char sortedlist[80], int n);

[Code].....

As you can see this will print out all frequencies that are bigger than 1, but I only want the highest frequency. Basically I want to print out all frequencies when count is greater than 1 less than count, but because its in a loop count will always be greater than count-1 so it prints out all frequencies.

View 3 Replies View Related

C/C++ :: Expected Outcome Error On X Amount Of Rolls

Feb 20, 2015

I have a program that rolls two dice however many times the user specifies and counts the occurrences of each total (2-12). I have to compare the results of the random rolls to the expected outcome and give the percentage of error between the two.

I have an example that tells me the sum to expected outcome are as follows if I roll 36 times: 2/1, 3/2, 4/3, 5/4, 6/5, 7/6, 8/5, 9/4, 10/3, 11/2, 12/1 but I don't know how to put that into code to get the expected outcome for X amount of rolls.

View 11 Replies View Related

C++ :: Non Printable Character TAB?

Apr 10, 2014

Why TAB with ASCII value 9 is non printable character and SPACE with ASCII value 32 is printable?I can open any editor and press any of them and I see it on screen(If I press tab cursor is moved by tab, and space if I press space)....

Then why one of them is printable and other non printable?

View 5 Replies View Related

C++ :: Find Non Printable ASCII Value - Using Library File Unittest

Jan 3, 2014

My program is find non printable ASCII value(1 to 32) and calculate count from a text like "hi<tab>this<space>my text.i'm using library file here.(visual studio 2012)

removeascii.h(program name)
#pragma once
#include<stdint.h>
#include <string>
using std::string;
namespace ascii

[Code] ....

My ERROR is:

1>c:program files (x86)microsoft visual studio 11.0vcunittestincludecppunittestassert.h(65): error C2338: Test writer must define specialization of ToString<const Q& q> for your class class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >

[Code] ....

View 1 Replies View Related

C++ :: Letter Frequency For A Vector

Nov 9, 2013

I am trying to print out the letter frequency of a vector that the user inputs and what number that letter is in the ASCII. I am supposed to say, for example: "w" which is ASCII 119 occurs 2 times. How to do this?

View 1 Replies View Related

C++ :: Letter Frequency Count

Nov 13, 2013

I am new to c++. I am writing a program that reads in a text file and gives a count of how many times each letter appeared in the file. I got it to read the text file and do the letter count. B

X = 102
Y = 126
Z = 165
etc...

THAT IS WORNG

The sample output should be
E = 165
T = 126
A = 102
O = 93
etc...

I got it to sort from lowest to highest for the frequency, but cant seem to get the appropriate letter assigned to it.

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

[code].....

View 1 Replies View Related

C++ :: Word Frequency In A Text

Dec 7, 2013

This program counts how many times does a word appear in a text. Why i have to add 1 to p in the while loop?

#include <iostream>
#include <cstring>
using namespace std;
char s[200], c1[20], *p;
int main() {
int k=0;

[Code] ....

View 1 Replies View Related

Visual C++ :: CPP High Frequency Trading

Jul 15, 2014

I have taken a keen interest in writing trading programs. I have some Python background, a little C# but no C++.

The example below was provided in a book on HFT and I would love to see how the results look. I was hoping that I would just compile it and away you go!

That didn't happen. To start with the author listed this as a function, so I converted it to a main program. Still having issues with my path and where to see the output. Here it is..

Code

void HFT_AvellanedaStoikov() {
FILE* fin, *fout;
double lambda_a, lambda_b, d_lambda_a, d_lambda_b;
int hh = 0, mm = 0, ss, nb = 0, na = 0, prevnb = 0, prevna = 0, prevm = 0;
double bid, ask, prevbid = 0, prevask = 0;
char * p1, *p2, buffer[1024], fname[512];

[Code] .....

Here is some data:

14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
14 49 24.37 24.38
.... and so on ....

View 3 Replies View Related

C :: Incorrect Values In Array

Apr 6, 2014

I have this simple program below:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
unsigned long long int address;
float current;
unsigned char pressure_units;
} sensor;

[Code]...

As you can see, it has stored the last struct in all three indexes of the array. Why?

View 1 Replies View Related

C++ :: Incorrect Length Of Array?

May 24, 2013

i having a code to pass in array as argument, but the length returned is 1. This is not match with the array size.

int Getsize(int Array[])
{
int len = sizeof(Array)/sizeof(int);
cout << len << "
";
}
int main()
{
int X[] = {45, 12, 54, 83, 41, 36};
getsize(X);
}

View 19 Replies View Related

C++ :: RGB To HSL Saturation Close But Incorrect

Feb 9, 2014

Currently I am trying to convert RGB to HSL. Everything is working but the saturation value. It is always close to the correct value (usually less than 10 off). For example:

RGB:(196,72,84)
HSL:(354,-46,52)
Correct HSL(354,51,53)

CODE:

double s=0;
double l=0;
chroma=max-min; //works correctly

//LIGHTNESS
l=(max+min)/2;

//SATURATION
if(chroma==0) {s=0;}
else {s=chroma/(1-fabs(2*l-1));}

s=s*100.000000;
l=(l/255.000000)*100.000000;

View 5 Replies View Related

C/C++ :: Output From Array Is Incorrect?

Apr 25, 2015

I am writing a program where I read in data from a file into an array and a 2D array. However, when I cout that data to insure that it was all read in correctly, I get only the first full line of that input file(where there are actually 25 rows and 12 columns).

What am I doing wrong or should be doing differently?

ifstream fin;
//open the input file
fin.open("store_data.txt");
//If input file was opened, read input file data into array and 2d array
if(fin){

[code]....

View 1 Replies View Related

C :: Find Highest Frequency Character In A String

May 17, 2014

The code shows all characters frequency, however i want to find which one has highest frequency

For example cprogrammmmming cboard
highest frequency: m

Code:
char string[100], ch;int c =0, count[26]={0};
printf("Enter a string
");
gets(string);

[Code] ....

View 3 Replies View Related

C++ :: Find Frequency (string Into Struct Array)?

Apr 17, 2013

I'm trying to figure out the word frequency of a user inserted string. I've tried doing it via getline of the struct array and via the getline of the string word but neither either the former crashes or the latter just prints out the whole string.

Here is the latter.

#include "stdafx.h"
#include <iostream>
#include <string>
#define MAX_WORDS 200
using namespace std;

[Code] ....

How to handle the array of structs.

View 5 Replies View Related

C++ :: Return Maximum Frequency Number From Stack

Dec 17, 2013

I designed one mfc vc++application in which data received from udp is stored in file as well as in stack.I used stl for stack; it stored elements as per receiving order,but i want to return repetitive number from stack,how to use stack as function parameter & retrieve elements of stack as an array? I write code for push elements in stack given below.

<template< typename T > void pushElements( T &stackRef,int value) {
stackRef.push( value);
}/>

View 1 Replies View Related

C/C++ :: Finding Highest Frequency Character In A String?

May 17, 2014

the code shows all characters frequency, however i want to find which one has highest frequency for example cprogrammmmming cboard highest frequency: m

char string[100], ch;int c =0, count[26]={0};
printf("Enter a string");
gets(string);

[Code].....

View 8 Replies View Related

C++ :: Incorrect Operands And Undefined Identifier

Apr 25, 2013

I'm writing a program to read in a Master.txt file and then update it through a Transaction.txt file that contains various transaction types [Adds (A), Deletes (D), and Edits (E1-E4)]. The records in both files are in ascending order based on Item#. Ultimately, the original Master.txt and updated Master file (Master2.txt) will be merged to reflect all valid transactions, and an errorLog.txt file will be created to indicate all invalid transactions. I feel I have all of the code written correctly, but I am still getting errors on my operands and identifiers.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct invRecord {
string delDate;

[Code] ....

View 7 Replies View Related

C++ :: Error - Declaration Terminated Incorrect

Aug 6, 2014

PROGRAM:-
#include<fstream.h> //for reading and writing files
#include<conio.h> //for clrscr()
#include<string.h> //for string characters
#include<stdio.h> //for gets and puts function
#include<process.h> //for exit function
#include<iomanip.h> //for setw function
#include<dos.h> //for delay and sleep function

void main()
{ char ch,c=0,che=16;
int i=1,j=16;

[Code] .....

View 6 Replies View Related

C++ :: Linked List Output Incorrect?

Oct 30, 2013

Were are to implement a method countValue() that counts the number of times an item occurs in a linked list. Remember to use the STL <list>

int countValue(list<int> front ,const int item);

Generate 20 random numbers in the range of 0 to 4, and insert each number in the linked list. Output the list by using a method which you would call writeLinkedList which you would add to the ListP.cpp.

In a loop, call the method countValue() , and display the number of occurrences of each value from 0 to 4 in the list.

Remember that all the above is to be included in the file ListP.ccp

The output should be:
2 3 4 0 1 0 2 4 2 3 3 4 3 3 3 0 0 2 0 2

0 : 5, 1 : 1, 2 : 5, 3 : 6, 4 : 3

but I am getting:

1 2 4 0 4 4 3 3 2 4 0 0 1 2 1 1 0 2 2 1

0 : 4, 1 : 5, 2 : 5, 3 : 2, 4 : 4,

Here is my code:

#include<iostream>
#include<list>
using namespace std;

[Code].....

View 1 Replies View Related

C++ :: Incorrect Result In Bitwise Operations?

Oct 30, 2014

I'm doing a bitwise operations on 2 bytes in a buffer, then storing the result in a variable. However, I sometimes get a non-zero value for the variable even though I'm expecting a zero value.

The relevant portion of the code is as follows.

unsigned int result = 0;
long j = 0, length;
unsigned char *data;
data = (unsigned char *)malloc(sizeof(unsigned char)*800000);

[Code] ......

I'm expecting result to be zero when my data[j] and data[j+1] are 0xb6 and 0xab respectively, which is the case for most of the time. However, for certain values of j, my result is strangely not zero.

j = 62910, result = 64
j = 78670, result = 64
j = 100594, result = 64
j = 165658, result = 512
j = 247990, result = 128
j = 268330, result = 512
j = 326754, result = 1
j = 415874, result = 256
j = 456654, result = 1024
j = 477366, result = 512

It appears that these strange result values are all powers of 2, with a 1 bit appearing somewhere in the unsigned int.

I'm not changing the value of result anywhere else in the code, and when I print out (unsigned int)(((data[j]^0xb6)<<8)|(data[j+1]^0xab)), I get 0, but somehow when it gets stored in result, it's no longer zero.

View 3 Replies View Related

C++ ::  keyboard That Counts Frequency Of Occurrence Of All Letters Of Alphabet

Mar 24, 2013

c++ program which reads an input stream from the keyboard that counts the frequency of occurrence of all the letters of the alphabet

View 5 Replies View Related

C++ :: Strings - How To Count Each Number Of Letters And Frequency It Shows

Apr 10, 2014

I try to use "rand" to create 100 string, I'm happy I succeed, but next step i wanna know how to count each number of letters and the frequency it shows.

Here is the code:

#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <iostream>
// using namespace std;
int main() {
const char *c = "abcdefghijklmnopqrstuvwxyz";

[Code] ......

View 1 Replies View Related

C++ :: 2 Arrays - Vector Outputs Incorrect Answers

Oct 19, 2014

Program: I have 2 arrays: 1 for the correct answers to a quiz, 1 for the user. I then have a vector to hold the incorrect answers. It keeps outputting what looks like alt characters, why.

Here is the code:

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

[Code] .....

View 2 Replies View Related

C++ :: Incorrect Vector Output Loop Error

Nov 21, 2014

My loop is outputting data incorrectly. I have inbound web data that come in sets of 7. I am trying to in insert the 7 records into a vector and then display the vector content followed by a new line.

Code:
char buff[BUFSIZ];
FILE *fp = stdout;
char * cstr = buff;
vector<std::string> vrecords;
while(std::fgets(buff, sizeof buff, fp) != NULL){
for(int i = 0; i < 6; ++i){

[Code] ....

expected output:

Found buy!
198397652
2014-11-14 15:10:10
Buy
0.00517290
0.00100000
0.00100000
0.00000517

[Code] ....

View 14 Replies View Related







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