C++ :: Create A File Which Containing Letters Related With Above ASCII?

Aug 30, 2014

I have a text file which contains ASCII of A,B and C like below,

65
66
67

Now I need to create a file which containing letters related with above ASCII like below, ABC

This is my code.

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

[Code]....

View 2 Replies


ADVERTISEMENT

C :: Create ASCII Bar Graph Of Die Rolls

May 24, 2013

for an assignment we need to create basically a program that asks the user for the result of standard six-sided die rolls (numbers from 1 to 6). The program will prompt the user with "Enter a die roll or 0 to exit " for the first entry and Next die roll? for all subsequent entries. The program will continue reading die rolls from the user until the user enters 0. At this point, the program prints two newline characters (one blank line) and finally, the bar chart showing the number of times each die roll has been entered, and then terminates.If the user enters an invalid number, the program will just ignore it, and ask for another number. Only numbers 1-6 inclusive and 0 are valid.

Example output Enter a die roll or 0 to exit 6 Next die roll? 6 Next die roll? 7 Next die roll? 4 Next die roll? 0

[code].....

View 3 Replies View Related

C++ :: Class / Header File Related Errors

Sep 22, 2014

Here's my class/header, and Visual studio Output.

Injection point/instantiation.

int main() {
Player player;

Call to a public method:
while(!isWin("x", board) && !isWin("o", board) && whoGoesFirst == "p") {
printBoard(board);
board = player.playerTurn(board);

[Code] .....

Output:
1234
1
1> Player.cpp
1>c:users
sccdocumentsvisual studio 2012projectsprog 2100 - assignment 1prog 2100 - assignment 1player.h(10): error C2143: syntax error : missing ';' before '<'
1>c:users
sccdocumentsvisual studio 2012projectsprog 2100 - assignment 1prog 2100 - assignment 1player.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:users
sccdocumentsvisual studio 2012projectsprog 2100 - assignment 1prog 2100 - assignment 1player.h(10): error C2238: unexpected token(s) preceding ';'

View 2 Replies View Related

C++ :: Store Related Data Of Program Into External File?

May 14, 2013

How is it possible to store the related data of a program C++ into an external file (like as .txt) and retrieve it?

I want to write c++ program that can contain data members " id and phone"

like as
Code:
class profile {
private: int id,phone;
public:
void retriever() {
cout<<"Enter your ID: ";
cin>>id;
cout<<"Your Phone number is "<< phone;
};
}

avoiding formats in above class, purpose is to store data already in txt file with different id and phone numbers and it is to be retrieved by matching id number to txt file and viewing its related phone number.

View 1 Replies View Related

C/C++ :: Display Unique Date And Its Related Price Found In Txt File

Apr 23, 2015

Currently i have a system that will store user input into a txt file, and have a function that will compute the daily sales of the month(Check by system date month) and display the sales of the day and the grand total of that month.

Take for example, the system date now check that the current month is Apr. Below are my current output:

20Apr2015 $11.5
20Apr2015 $15.5
22Apr2015 $4.5
25Apr2015 $4.5
28Apr2015 $4.5
20Apr2015 $4.5
Grand Total $45

But my desired result should be as below

20Apr2015 $31.5
22Apr2015 $4.5
25Apr2015 $4.5
28Apr2015 $4.5
Grand Total $45

Textfile data:

1|Bag|2|3|6|20Apr2015
2|Fruit|2.3|5|11.5|20Apr2015
3|Fruit|2.3|5|15.5|20Apr2015
4|Water|0.9|5|4.5|22Apr2015
5|Water|0.9|5|4.5|25Apr2015
6|Water|0.9|5|4.5|20Jul2015
7|Water|0.9|5|4.5|20Jul2015
8|Water|0.9|5|4.5|28Apr2015
9|Water|0.9|5|4.5|20Apr2015

Below are my code.

struct TransactionPile {
// to record item information.
string itemid;
string itemdesc;
float unitprice;
int quantity;
float totalprice;
string date;

[Code] ....

View 6 Replies View Related

C/C++ :: Sorting A File Based On ASCII Values?

Sep 1, 2014

New file_sorter.c:

#include <stdio.h>
#include <stdlib.h>
#include "sort.h"
#include <string.h>

[Code].....

My issue is now a segmentation fault in my sorting algorithm. In my assignment I was suppose to implement quick and insertion sort for the file, and organised strictly by ASCII values. We were allowed to look up generic algorithms for the sorts, but we have to convert them to comparing char arrays.

I haven't started trying to configure quick sort yet, but I'll supply the generic algorithm as well. keep in mind that the first line in the file contains the number of lines in the file. I'll try not to disappear this time!

sort.c :
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>

[Code]....

View 4 Replies View Related

C :: Load Up File That Contains Series Of Int Values Stored In ASCII

Sep 23, 2013

This seems like a fairly straight forward assignment. Load up a file that contains a series of int values stored in ASCII and print out the ASCII characters to the console.

The problem I am having is that I am getting the numerical value of bytes ("40" for 10 numerical values, "200" for 50 values). The numbers are generated randomly by another file, but I can control how many numbers are generated. For example, if I type in:

shell% cat tempfile

the output is as follows:

/8?qE?. Y4?(T???a???%@

but when I try to run it with my program:

shell% ./intcat tempfile

the output displayed is:

40

Code:

#include <stdio.h>
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
//check if arguments match

[Code] .....

View 10 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++ :: Linked List - Friendship Of Functions Related To Classes

Jul 5, 2013

I'm developing a stack using a linked list. I have to develop two friend functions to do something with the list. But I've tried to understand the friendship, without any consistent result.

Extract of code:

Code:
class Element {
public:
int Data;
Element *nextElement;
Element(int Element) {Data = Element; nextElement = NULL;}
~Element() { }

[Code] ....

I have no errors, but I cannot access the private properties of the class.

The thing I would like to do is: sum the elements of the stack with a friend function.

View 7 Replies View Related

C++ :: Source Files Separation And Inter-related Classes

Feb 11, 2012

I have heard that people should implement their class member functions in files that are different from their class declaration files. But in cases there are multiple classes that are inter-related to each other, how will you review the source code ?

View 1 Replies View Related

C :: Sorting Letters As They Are Read From Text File

Apr 16, 2013

I have to write a function that reads letters one at a time from a text file, such as (aBCdefG) using fgetc(). However, each character needs to be inserted into the array in ascending ASCII order, so it should come out as (BCGadef). I wanted to use an insertion sort, however, that would require me to pass the whole array. My professor wants me to sort the letters as they are read, though, and not as a whole array.Can you even do that?

View 11 Replies View Related

C++ :: Count Letters From Text File Into Array?

May 10, 2014

I have to count the letters from a text file into an array so the first spot is the number of A's second spot number of B's and so on then take the array and sort it in decending order how could i do this without loosing track of where the numbers go so if there are more b's than a's they switch but how will i know where each letter has moved in the array after it has been sorted?

View 1 Replies View Related

C/C++ :: Uppercase And Lowercase Letters Count From File

Nov 11, 2014

char ch;
int uppercase=0;
int lowercase=0;
file.open(pav.c_str());
while(!file.eof()) {

[Code] .....

So I need to count uppercase and lowercase letters from file, and I always get 0. What is the problem with this part of code?

View 10 Replies View Related

C++ :: User Defined Function - String Related Program (swapping)

Jan 4, 2015

Write a program using user-defined function which is passed a string and that function should cycle the string.(Do not use any string related functions). E.g.

If the string is : Chetna then it should print as Chetna, hetnaC, etnaCh, tnaChe,naChet, aChetn

Ans.

#include <iostream>
using namespace std;
char swamp(char a[], int x) {
for(int k=0; k<=x; k++) {
char l= a[x]; a[x]= a[0]; char p=a[x-1]; a[x-1]=l;
for(int i=1; i<x-2; i++) {

[Code]...

View 19 Replies View Related

C :: Converting A String Array Into Uppercase Letters From File

Apr 19, 2013

I am new to coding Here is the problem. Have a program prompt the user for a filename to open. Change every alphabetic character in the file to a capital letter. Numbers and special characters should not be changed. Print the output to the screen.

Here is my code so far but i am only returning the last line of text capitalized from the file. I am trying to get the program to display all of the three lines of text from the file capitalized. The program displays the file correctly before i try and convert everything toupper();

Code:

Code: #include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
int main()
{
char line[81], filename[21];
int i;
FILE *inFile;

[Code]...

View 6 Replies View Related

C++ :: Reading Binary File / Doesn't Read All Letters

Mar 2, 2013

I'm reading a binary file and I want to read all of the letters, but I have noticed that it doesn't read all of the letters and I think it is because of appears as data.

View 11 Replies View Related

C/C++ :: Loading TXT File To Convert Letters To Numbers And Export Again

Feb 5, 2015

I have been playing around with .txt and .dat files lately. I only manage to load the files, but I don't seem to be able to load files using a variable.

Also modifying the data after it is imported is also currently problematic. I know how to go about the process without the need to import anything, but whenever I import the data I am having trouble modifying/ editing the ".txt" or ".dat" data.

Below is my current code:

#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
ifstream file;
ofstream result;
char in_file_name[8], out_file_name[8];

[Code] ....

View 5 Replies View Related

C# :: Create Project That Create Automated Backup Of File

Apr 10, 2014

I need to create a project that create a automated backup of a file.

i will get the file from C:/Folder/file.exe and move for a other created folder, but.. in every time that user make this backup, a folder will be created with year, month and date, like: C/Folder2/2014/April/16:42/file.exe.

View 4 Replies View Related

C :: Create File To Write Text And Read Back The File Content

Mar 15, 2013

The Objective Of This Program Is To Create A File To Write Text And Read Back The File Content. To Do That I Have Made Two Function writeFile() To Write And readFile() To Read.The readFile() function works just fine but writeFile() doesn't.

How writeFile() function Works? when writeFile() function Execute It Takes Characters User Type And When Hit Enter(ASC|| 10) It Ask "More?(Y/N)" That Means What User Want? Want To Go Next Line Or End Input?

If "Y" Than Inputs Are Taken From Next Line Else Input Ends.

But The Problem Is When Program Encounters ch==10 It Shows "More?(Y/N)" And Takes Input In cmd variable.If cmd=='Y' I Mean More From Next Line Than It Should Execute Scanf Again To Take ch I Mean User Input.But Its Not!!! Its Always Showing "More?(Y/N)" Again And Again Like A Loop.

Code:
#include <stdio.h>
void writeFile(void);
void readFile(void);
int main(){

[Code].....

View 5 Replies View Related

C++ :: Create File With Given Size And Then Randomly Access File To Populate It

Feb 17, 2015

I am interested in creating a file of a given size and then randomly accessing the file to populate it. Is there a way to quickly create, for instance, a 4 GByte file in C++, initially populated with garbage?

View 4 Replies View Related

C/C++ :: Pass Path In File Handling To Create Or Open A File?

Jul 14, 2012

I have a folder "pics" in g: drive. There I want to create some text.txt file. Thus, the final path is "g:pics ext.txt".

How can I do that?

View 3 Replies View Related

C++ :: Create Save File For A Game That Is Not A Separate File?

Oct 10, 2014

How do you create a save file for a game, that is not a separate file? Specifically I am using code::blocks and sfml 2.1 to make a game and it saves to a text file at the moment. My problem is that it is very easy to modify the text file, and it is annoying to have to copy and paste several files if you want to use a copy of the game. I have a feeling that it may be to do with resource files, but I'm not exactly sure how to get these to work or whether you can modify them dynamically.

View 6 Replies View Related

C++ :: How To Use ASCII Art In C

Feb 26, 2014

How do I print this without generating errors?

Code:

printf(" ||====================================================================||
");
printf(" ||//$///////////////////////////////$||
");
printf(" ||(100)==================| RESERVE BANK OF INDIA|================(100)||
");
printf(" ||$// ~ '------========--------' $//||

[code].....

View 8 Replies View Related

C++ :: Convert Hex To ASCII

May 7, 2013

I want to convert Hex:390041 to ascii "90A",

39: 9
00: 0 -->Null
41: A

i am getting only "9" in the bytearray,i know 0 is terminating the array

unsigned int bytes[3];
int j=0,counter=0;
char c[2];

[Code]....

View 1 Replies View Related

C++ :: Subtracting ASCII Hex Value In 64 Bit Hex Value

Mar 31, 2015

I have some ascii characters in a char variable.ex - char buf[100]="ab*(z&";

So each of the char in that char array will have some hex value.ex- *'s hex value is '2a'.

And I have a long long int variable in which there is a 64 bit hex value.

ex- long long int k=0x0000888888888888;

Now i want to subtract the char buff's hex value in k. How to accomplish it.

That is 0x0000888888888888
- 0x000061622a287a26
= 0x000027265e600e62 (final result in a buffer or a long variable is okay)

Later i want to reverse the result as 26e006e56272.It should be stored in a variable such that i should be able to access each byte from it(ex- '72'(last 2 hex digits))

View 1 Replies View Related

C :: How To Find ASCII Value Of Given String

Aug 25, 2013

I know how to find find ASCII value of given character, but I am not getting how to find ASCII value of given string. For example I want to find ASCII value of string "HELLO",so how to do that.

View 13 Replies View Related







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