C++ :: Check The Coding Style Use In A Program?
Apr 30, 2014Is there any opensource tool which can check the coding style use in a program.
View 2 RepliesIs there any opensource tool which can check the coding style use in a program.
View 2 RepliesIs 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 RelatedWrite a program that will input the amount of chairs sold for each style. It will print the total dollar sales of each style as well as the total sales of all chairs in fixed point notation with two decimal places.
The program runs fine I am just have problems with the output. I have tried a few different methods for the fixed point notation, but I am getting results like 324.5 rather than 324.50?
#include <iostream>
using namespace std;
int main() {
//Declares variables for chairs
float americanColonial;
float modern;
float frenchClassical;
[Code]...
some where in main:
char value;
char* sname;
sname= new char[20];
for(int i=0;i!=19;i++)
{
cin>>value;
sname[i]=value;
}
I need a stopping case when user press enter array get closed and add '' at the end but how to do that?
I just spent 3 hours writing and debugging 37 lines of code. Is this normal or am I "below average" in coding abilities. I come from a C background and decided to write C++ code that I finally got right as shown below for the specific example:
Code: #include <iostream>
#include <fstream>
#include <string>
#define SPACE_SEARCH 10
using namespace std;
[code].....
I think it was more the learning along the way that consumed atleast 75% of my time for this specific case. But then again, I read that programming always entails learning along the way and so its somehow no excuse for the long time taken in this specific case.
So as a matter of interest, what pace do all of you operate on, on average? i.e. LOC/day, Debugs per day or any other indicator of productivity?
I'm interested in learning how to write the software for audio synthesizers. a friend of mine started on the hardware side for them and, as i have no experience with this type of code.
View 7 Replies View RelatedIm having problems coding this
A = P(1 + r/n)nt
//Declared test cases
float principal = 200000.00, annualInt = 0.03;
float years = 10.0;
float calcInterest1(float principal, float years, float annualInt) {
float interest1;
float nt = annualInt*12;
float A = principal+annualInt;//Accrued Amount
interest1 = (A = (principal*(1+years/100))pow(nt));// A = P(1 + r/n)nt
return interest1;
}
Write a program that computes how many feet an object falls in 1 second, 2 seconds, etc., up to 12 seconds.
1.Have a procedure called FallingDistance which has one input parameter, seconds, and one output parameter, distance.
2. Compute the distance in feet an object falls using this formula: d = ½ gt2
(where g = 32.2)
3. The main program should call FallingDistance within a loop which passes the values 1 through 12 as arguments.
4. Print a table with seconds and falling distance in feet.
Sample Output (This program has no input)
Seconds Distance
================
1 16.1000
2 64.4000
3 144.9000
4 257.6000
5 402.5000
6 579.6000
7 788.9000
8 1030.4000
9 1304.1000
10 1610
11 1948.1000
12 2318.4000
In C++, the procedure is called a function. Instead of using an output parameter, your C++ function FallingDistance should return a result of type double. This is what I created:
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
const double g =32.2;
double fallingDistance(double);
[Code] ....
which gave me this error:
1>------ Build started: Project: Lab 6, Configuration: Debug Win32 ------
1> Source.cpp
1>c:usershanahdocumentsschoolprogamming ilab 6lab 6source.cpp(27): error C2065: 'fallingdistance' : undeclared identifier
1>c:usershanahdocumentsschoolprogamming ilab 6lab 6source.cpp(36): error C2065: 't' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I java We can be able to open any application through coding.. likewise Is it possible to open through c++?
View 3 Replies View Relatedin order to calculate some logarithm approximation I need to make a variable, say s, search through the whole integer numbers.
Code:
int s;
for {;;s++){
}
[Code] ....
since the variable needs to be initialized right? how to go through all the numbers?
I am writing a program where all work is done in the class methods. Main is used to call the methods. I need to know how to get a loop to work without any variables in main that can be used outside the methods. This is what I have in main:
#include <iostream>
#include <string>
using namespace std;
#include "FerryBoat.h"
int main() {
//create a constructor for a ferry boat
FerryBoat myBoat('B', 20, 'A');
[Code] ....
I could not find the mistake in this program....
Code:
//cpp program to check whether a number is palindrome or not
#include<iostream.h>
#include<conio.h>
//the class
class palindrome
[Code] ....
I get this error..In function 'main':
p6.c.text+0x6a): undefined reference to 'palindromeness'
collect2: 1d returned 1 exit status
This is program is suppose to check if a phrase is a palindrome or not.I need to write a function definition for _Bool palindromeness(char str[])but I am having a tough time figuring that part out. I am brand new to programming..this is my first class and I am just learning arrays and pointers.
I'm writing a program to check whether codes from a file are invalid, valid, inactive, or valid and active, but can't get it to work properly. The invalid codes are being found, but the other three are not. I think it may have something to do with my "active" function.
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
using namespace std;
struct ActiveCodes {
string code;
bool flag;
[Code] ....
Check the Leap Year Program In C++:
#include <iostream>
using namespace std;
int main() {
int yr;
cout << "Enter year : ";
[Code] ....
Check the LeaP Year... [URL] ....
So I've been tasked with creating a program that checks to see whether or not a string is a palindrome. It has to remove whitespace, punctuation, and capitalization for obvious reasons. Getting some errors which I'm not sure how to correct.
On an unrelated note, while programming in the console, my cursor has turned into a gray box and replaces characters when typing, instead of pushing them forward, etc. How do I return it to normal?
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
bool isPalin(string& palin);
string cleanUp(string& palin);
[Code] .....
What is the minimum range of numbers which we need to go necessarily to check either a number is prime or not?(for all integers) ....
View 6 Replies View RelatedI am trying to create an on-line product store. I'm having trouble with setting up the code to correctly acknowledge quantity desired per product item in the shopping cart at check-out. I want to be able to capture multiple impressions/hits/clicks per item and increase the # in the quantity box each time someone clicks on the same item. For example, if product A is clicked 3 times, then the quantity in the shopping cart should show "3". If it's clicked 5 times, it should show "5" and so on ... However, right now, it's showing the product multiple times in the shopping cart with a quantity of "1" for each time the item was clicked. How can I correct this?
View 2 Replies View RelatedCasting Pointers in C Programming. I don't want to move onto implicit casts until I have this down pat. I'm failing to understand how casting pointers works.
The line
int *mnt = (int*)&flt;
if I read this correctly passes the address of flt which has been converted to an int to the pointer mnt.
1 - When I output mnt I get a garbage value, probably because the address of flt is then converted to a pointer and passed onto mnt as a value and then reinterpreted as a memory address. (that is the first part I don't understand)
2 - - What exactly does the (int*) cast say? Does this mean that a pointer will be returned or an address will be returned. What does the fact that the * is inside the parenthesis mean?
Code:
#include <iostream>
using namespace std;
int main() {
float flt= 6.5;
int *mnt = (int*)&flt;
cout << mnt << endl; // outputs hex memory address
cout << *mnt << endl; // outputs garbage value
}
Program is supposed to check for balanced parentheses which are (), {}, [] using a vector First read in the number of lines user wishes to testReturn Yes if balanced, No if unbalanced. Missing conditions to check for unbalanced parentheses Program doesn't catch left parentheses returns YesPairs wrong parentheses together, (} returns Yes, should be No Cases with incorrect output (}, (], ))), }}}, ]]], just a space or nothing entered. how I can correctly catch the cases I've missed
Code:
#include <stdio.h>
#include <stdlib.h>
#include "char_vector.h"
int main( int argc, char * argv []) {
int i, num;
char c;
scanf("%d", &num);
scanf("%c", &c);
[Code]...
So I have to write a program that outputs a check with correct spacing and everything.
Create a project titled Lab7_Check. Write a program that asks the user the check information and prints the check. The dialog should be as follows:
date: 2/23/2010
name: William Schmidt
amount, dollars: 23
cents: 30
payee: Office Max
your check:
William Schmidt 10/13/2013
pay to: Office Max $23.30
twenty three and 30/100 dollars
You may assume that a person always has the first name and last name (no middle names or initials). The payee name is also always two words. The dollar and cent amount are integers and the amount is always less than 100 dollars. Note that the dollar amount could be zero, in which case, when you spell the dollar amount, it should print "zero". The date is always a single (non-white space separated string). Your date, dollar amount in numbers and the word "dollars" have to vertically align.
This is the code I have so far.
#include <iostream>
#include <string>
using namespace std;
int main(){
string date;
string firstname;
string lastname;
[Code] .....
How would I check for proper data type when someone is to input a value into the program? Ex:
int i;
string a;
cout << "Enter a number: ";
cin >> i;
cout >> "Enter a string: ";
cin >> a;
How would you check to make sure that int i would be an actual number and not a letter like "a"?
add more code given bellow program that means (( you can input a password and the output checking the password is valid or not and also the password is hard or weak)) the program,s output show....the given password is too strong or strong or weak and also check the password is valid
View 2 Replies View RelatedI want to write a command line parsing library that is very flexible in terms of parsing style but I'm not able to design a mechanism that satisfies this requirements.
Generally i want to have a class that contains all the necessary information about how the command line has to be parsed.
Code:
// draft
class style {
public:
enum class type { // the basic style type
[Code] ....
Need completing the draft shown above, because for every basic style type there is an own set of extensions that applies only to this one specific style type.
Code:
// how a style object should be created
style parsing_style(style::type::posix, style::extension::gnu|style::extension::subcommand);
How to design the class. (using c++11 features like std::enable_if is fine)
I need to convert a string into a Font object. I'm trying to use the Font Converter but I don't see support for the font Style. I need to save a font to a string and back again using the font name, size and style.
Font font1 = (Font) converter.ConvertFromString("Arial, 12pt");
I was told that if I define
char *cstrp;
char cstra[c];
then the cstrp can be treated as cstra, and so I can also use
cin>>cstrp;
but when I write the following program, I find it don't work, don't have clue
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main() {
char cstr[5];
[Code] ....
for cstr, it work exactly as what I expected, but for cstrp, no matter what I input, with a null terminator or not, I just got nothing printed. why? can we really use cstrp in that way or not? How to use it?