C/C++ :: Program Which Removes Notes From Program File

Mar 10, 2014

so my homework assignment is to make a program of which removes any notes in a program file.

for example, you run my program it will ask for a filename, when entered it opens the file, copies everything in it and removes any double forward slashes (//) and anything after that up to the new line character ( ) and anything between /* and */ including the /* and */.

i created the entire program and it removed the // and anything after that up to the new line character but will not remove anything after the first / when it finds a /*. This includes the */ at the end of the comment.

the section of code that removes the comments is

//this loop removes all notes
for(i=0;i<buf.st_size;i++) {
if((filecontent[i]=='/')&&(filecontent[i+1]=='/'))//removes notes using //
{
for(i=i;filecontent[i]!='
';i++)
filecontent[i]=' ';}

[Code]....

i know that the section that removes the multi line comments would not remove the final */ at the end if it did work, i was planning to fix that later once it removed the comment.

View 6 Replies


ADVERTISEMENT

C :: Are Musical Notes Valid In Program

Jul 21, 2013

Is this a good way of writing this program?I wanted to start fresh with my new code though and a better title.Basically, I took what I learned from my questions in that thread and managed to build a list of musical notes( octaves, frequencies, sharp symbols, basically everything ).

Code:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX_NOTES 88 /* 88 keys on a standard piano */

[code]...

I already know the frequencies are correct( they are rounded, but they should be close enough to the value ), but I wasn't so sure about the note labels. Obviously though, I'm not done with this program and I will be adding most of the functions Anduril suggested to take a text file and convert it into music. I just wanted to make sure I had everything correct before moving on. I probably didn't do the GetNextOctave() and GetNextNote() functions very efficiently so need suggestions on those functions also.

View 3 Replies View Related

C :: Program Crashes When Parsing Musical Notes From It

Jul 23, 2013

I have the text parser done, but when I use it, the program crashes. Just because of how I test my code, I know the section where it occurs, but I'm not sure what the exact problem is ( no errors or warning, so it's just something I don't see ). Here is the full code

Code: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

[Code].....

I probably made a mistake in the way I allocated memory or tested values, but I'm not sure where it is in my code. Currently it just prints out "Failed to parse data on line 1" then crashes. Here is the text file I give to this program.

Code:
A#3 500 A#3 500 A#3 500
rest 1000
B#4 500 C3 500

View 7 Replies View Related

C++ :: How To Write A Program That Count Number Of Notes

Sep 17, 2014

How we will write a program that will count a number of notes. I mean if i have 5676 rupees and i want to find the number of 5 thousand pak currency ,the number of 1000 notes, the number of 500 notes and the number of 100 notes. How we design such a program of if rlse structure to perform the above task.

View 1 Replies View Related

C++ :: Removes All Prime Numbers From A Vector

Jun 27, 2013

I am trying to implement a method that removes all the prime numbers from a vector. They are all numbers from 0 to num, where num in given by the user.

void
findVectorPrimes(int num, set<int>& primes) {
int squareRoot = sqrt(num);
vector <int> v;
vector<int>::iterator m = v.begin();

[code].....

There is a separate method that fills the vector.Its giving me an error and I can't seem to figure it out. Here is the error...

seive.cc:121:35: error: no match for âoperator*â in âv.std::vector<_Tp, _Alloc>::begin<int, std::allocator<int> >().__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+<int*, std::vector<int> >((* &((__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)m.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<int*, std::vector<int> >()))) * kâ

View 6 Replies View Related

C++ ::  assignment Is Recursive Call And Placing Strings In Linked List Notes

Oct 24, 2013

You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.

The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.

Write a driver to test the permute class to pass in any two strings of any sizes.

Other than mention in the following, you can add more classes, functions, and private data members to this program.

Note class

The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.

Permute class

The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.

There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.

Driver file

The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",
first = "", second ="CATMAN",
first = "C", second ="ATMAN",
first = "CA", second ="TMAN",
first = "CAT", second ="MAN",
first = "CATM", second ="AN",
first = "CATMA", second ="N",
first 1 = "CATMAN", second ="";

View 19 Replies View Related

C++ :: Creating Infinite Sheet On Which User Can Write Notes And Place Images

Dec 31, 2012

I'm new to c++ and I want to create an infinite sheet on which a user could be able to write notes and place images. Any GUI library that I could use to do that?

View 2 Replies View Related

C :: Program To Calculate Students Grades From Input File And Write To Output File

Aug 29, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:

John K. 99, 87, 57, 89, 90, 95
Amanda B. Jones 100, 88, 76, 99, 86, 92
etc..

The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.

Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:

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

[Code]....

View 2 Replies View Related

C/C++ :: Program To Compute Students Grades From File And Write Them To File?

Aug 31, 2014

We have to write a program that reads an input file containing data in the form:

Martha J, 80, 90, 90, 100, 89, 99, 85
Anna Smith, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 89, 62, 65, 60, 50
...etc...

and then use that information to determine their letter grade and write that information to a .txt file. I have been able to successfully pass that information to a function to determine their letter grade and have been able to successfully compute their letter grade. However, I can get this information to successfully post within the *computeGrade () function. Yet, I don't know how to pass this information back to the main() on a student by student basis so that I can open a new .txt file and write just their name and letter grade to it.

Another issue I'm having is when it comes to computing the averages of the class. Each score is either a quiz (there are 4), a midterm (there are 2) or a final (there is 1). I'm a little stuck on how to pass say all of the quiz 1 grades as one entity to the function averagesminmax(). Is there a way to compile each of the grades for a specific quiz or midterm as one array and pass that to the function to then do the computation. Also we need the min and max so again from compiling the grades of a particular quiz or exam together as one.

Here's the code that I have so far.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const char *computeGrade();
int averagesminmax();
int main() {
char fName[20];
char lName[20];

[code]....

Do I need to re-read the input file and assign them to different variables?

Here's a sample of the output so far:

Enter input .txt file name
Graded
Thui Bhu, 91, A
Ariana B. Smith, 96, A
Emily Gonzales, 83, B
Jennifer L, 89, B
Maria Jones, 67, D
Bill Gates, 55, F
Escobar Morris, 78, C
Anne Latner, 88, B
Program ended with exit code: 0

Also in my output file, the only thing that it prints will be the first name of whatever the last student in the input file list is.

View 2 Replies View Related

Visual C++ :: Assignment Is Recursive Call And Placing Strings In Link List Notes?

Oct 30, 2013

You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.

The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.

Write a driver to test the permute class to pass in any two strings of any sizes.

Other than mention in the following, you can add more classes, functions, and private data members to this program.

Note class:The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.

Permute class:The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.

There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.

Driver file:The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",

first = "", second ="CATMAN",

first = "C", second ="ATMAN",

first = "CA", second ="TMAN",

first = "CAT", second ="MAN",

first = "CATM", second ="AN",

first = "CATMA", second ="N",

first 1 = "CATMAN", second ="";

View 3 Replies View Related

C++ :: File Handling - Program To Read Inputs In TXT File

Mar 26, 2013

I've written a program to read inputs in a text file. The file named Input.txt contain integers 2 3 and 4. My program is as follows:

#include<iostream>
#include<cstdlib>
#include<fstream>
using namespace std;
int main (){
int x,y,z;

[Code] ....

the program is outputing x=2293616 , y=0 and z=0 instead of x=2, y=3 and z=4.

View 9 Replies View Related

C++ :: File Operations Inputting A File Into Program

Jul 28, 2014

I keep getting this error when trying to compile.

error C2440: 'initializing' : cannot convert from 'void' to 'std::basic_ifstream<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> Expressions of type void cannot be converted to other types

Here is my entire program:

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

[code].....

View 13 Replies View Related

C++ :: Program With Do-while Loop To Restart Program And Validation

May 11, 2013

I am having problems at the end of the program with the do-while loop to restart the program and the validation.

#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <time.h>
using namespace std;

[code]....

View 3 Replies View Related

C++ :: Open Exe File From Program?

Apr 15, 2013

I am wondering how can i open a .exe file with my c++ program. What is the source code?

View 6 Replies View Related

C :: How To Create A Program That Take AVI File

Jan 26, 2015

I want to create a program that would take an AVI file, alter each frame (ex: change contrast, invert colors, etc.) and dump a new AVI. I've wrote a simple program for this experiment that loads up the header information from the video and dumps it. It also dumps a list of the frame data chunks within the 'movi' chunk.

The info I've gathered from coding this:

1. The recommended buffer size for each type of stream (vids, auds, etc.) is the size of the largest frame of corresponding type, plus 1 or two extra bytes.

2. numFrames in main header is the total number of frames for all types of data (video,audio,etc.) The 'length' value within stream header of type 'vids' is the number of video frames. The sizeImage value within BITMAPINFOHEADER is 921600 (==640*480*3) and the specification states that, quoth, "This can be set to 0 for uncompressed RGB bitmaps."

3. This video uses DIVX encoding.

Now my problem is this: How do I get the data within each video frame in a simple BMP like format? Even the uncompressed frames (with chunk id 'nndb') have variable sizes...let alone the compressed ones.

Information about a software that converts AVIs to a format with fixed sized uncompressed frames. Or at least some information about the frame decompression techniques.

Here's a dump made by the program for a 9 sec, 640x480 video I recorded from Pokemon. (Without the frame dump that is, it'd have made the post too long.)

Code:

AviMainHeader
-------------
size = 56
usecPerFrame = 66666
maxBytesPerSec = 7680000
padSize = 0
flags = 0x00000810
numFrames = 162
initialFrames = 0
numStreams = 2

[Code]...

View 4 Replies View Related

C :: Self Deleting Of EXE File By Program Itself

Sep 10, 2014

How to do self deleting of exe file when it is run'd.

View 2 Replies View Related

C :: Program To Output PPM File

Oct 8, 2014

How do you make a program output a ppm file?

Code:
#include <stdio.h>
void make_pixel
(
int r, // red intensity

[Code].....

View 7 Replies View Related

C :: Coding MP3 File Into A Program

Oct 16, 2013

Is there a way to put a mp3 file into a c program without having the windows media player pop up in the background each time you compile the program? I just wanted to input a few seconds of an audio file..

View 3 Replies View Related

C++ :: How To Play WAV File In A Program

Mar 6, 2014

I understand how to play a .wav file in a program, but I am attempting to "package" the .wav file with the project so that it can be played by another person, on a different machine (namely, my professor). The way I have come to understand this is that if you use the following line of code:

PlaySound(TEXT("C:WindowsMedia
otify.wav"), NULL, SND_FILENAME);

The sound file would not play if it is not in the same location on the other computer. Am I correct? Assuming that I am, I have added the file that I wish to play as a resource in my project, but I can't figure out how to make it play. Looking at MSDN (and other resources) I found the following snippet:

#define MAKEINTRESOURCE
PlaySound(
MAKEINTRESOURCE(L"notify.wav"),
GetModuleHandle(NULL),
SND_RESOURCE);

I get no errors when I build the program, but no sound plays when I run it. I have tried for hours now to figure this out (which is usually enough time for me to sort through the problem) but I have met with no success. This leads me to believe I am either completely off in my assumptions, or I am making a silly mistake.

View 6 Replies View Related

C++ :: Make EXE File Using CPP Program

May 27, 2013

i need to write a program that when run makes another exe file . Eg: make a program named 'sxes' and compiled it. When i execute or run sxes a new exe file named 'new01.exe' is created. This new01.exe when executed must input two numbers and add them and print output. I want to write a program same as installer file .

View 11 Replies View Related

C++ :: FTP Program Compiling A File?

Mar 28, 2013

I have a FTP server, client program and thus I can easily transfer files, however what I want is to modify the program such that server receives a c/c++ file, compiles the output, and sends a text file back to the client containing the output. The program should also take note that errors are also transferred.

View 9 Replies View Related

C++ :: Reading File Twice In A Program?

Feb 13, 2015

how to read file twice in a single program?

View 4 Replies View Related

C++ :: Program To Add Extra B Before B In A File Containing ABC

May 17, 2013

Saw a thread about a program to add an extra 'b' before 'B' in a file containing 'ABC'. I tried it. Here's my code:

("file1.txt" contains "ABC")

#include<iostream>
#include<fstream>
using namespace std;
int main(){
ifstream in;
ofstream out;

[Code] ...

It works except an extra C appears at the end.

O/P in the file:

"AbBCC"

View 4 Replies View Related

C++ :: Program To Output Name From A File

Dec 10, 2014

I am trying to get my program to output the name from a file. The user should enter first name "or" last name. and if the user does not type the name from the input file. the get an error message. How do you do it

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;

const int NUM_STUDENTS = 17;
const int NUM_QUIZZES = 10;
const int NUM_EXAMS = 5;

[Code] ....

View 4 Replies View Related

C++ :: Program Not Reading TXT File

Jan 24, 2014

I have a program that makes a .txt file and I am trying to read it and it won't.

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

[Code] .....

View 13 Replies View Related

C++ :: Reading TXT File Into Program?

Mar 19, 2013

I'm working with parallel arrays, one handles the titles and the other handles the ratings. Now everything works fine if the title doesn't start with a number, but if I decide to use a number infront of the title, when it reads it from the .txt file it thinks it is part of the rating.

Here is what I mean:

1234567891011121314151617181920212223242526272829303132333435363738394041424344
LOADING DATA FROM FILE...
MENU
1. Add Movie
2. Print All
3. Exit
------------------------------------------------------
Enter 1-3 : 2
PRINT ALL
------------------------------------------------------
Hitch 98% FRESH
Happy Gilmore 99% FRESH
Transformers 2 100% FRESH
SpongeBob 10% ROTTEN
MENU

[code]....

As you can see, the '2' from 2 Fast 2 Furious went to the rating in SpongeBob.

Here is what it looks like inside the .txt file:

Hitch| 98Happy Gilmore| 99Transformers 2| 100SpongeBob| 102 Fast 2 Furious| 100

Here is my code:

void SaveToFile(const string titles[], const int ratings[], int count)
{
string filename;
ofstream outfile;
filename = "tomatoes.txt";
outfile.open(filename);
PrintToText(outfile, titles, ratings, count);
WriteLine(cout, '=', 54);

[code]....

View 3 Replies View Related







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