C++ :: Enter Value For Coding

Oct 1, 2013

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?

View 1 Replies


ADVERTISEMENT

C++ :: Coding And Debug Time Per LOC

Mar 23, 2013

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?

View 3 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 Start Coding Audio Synthesizers

Mar 20, 2013

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 Related

C++ :: Compound Interest Formula Coding

Sep 24, 2014

Im 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;
}

View 1 Replies View Related

C++ :: Check The Coding Style Use In A Program?

Apr 30, 2014

Is there any opensource tool which can check the coding style use in a program.

View 2 Replies View Related

C/C++ :: Falling Object Error When Coding

Mar 4, 2014

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 ==========

View 4 Replies View Related

C++ :: How To Open Notepad Application Through Coding

Aug 14, 2012

I java We can be able to open any application through coding.. likewise Is it possible to open through c++?

View 3 Replies View Related

C :: Got Stuck In Simple Coding Process / How To Initialize Any Value

Mar 2, 2013

in 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?

View 3 Replies View Related

C++ :: Coding A Loop Inside A Class To Use In Main

Feb 22, 2013

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] ....

View 3 Replies View Related

C Sharp :: Coding For Quantities In Online Shopping Carts?

Jan 11, 2013

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

C :: Cannot Enter Anything Else Than Name

Aug 10, 2013

insert Code: #include<stdio.h>
#include<conio.h>
struct prod
{
char name[25];

[Code]....

View 10 Replies View Related

C :: Flushing Input And Why Do Have To Hit Enter Key Twice

Mar 6, 2015

I wrote a program that reads user input string using fgets() function. After this, program will ask if the user wants to save the string to file or does the user want to change the string or quit without saving. If user wants to change the string this must be made possible by asking for the string again. After this, menu will be printed again printing the choices available.

I had to flush stdin before getting changing input! However, problem is "Why do I have to hit return key 2 times, when I choose 2 and input string again." (I use code block 13.12 with windows 8.1 laptop) */

Code:
#include <stdio.h>
#include <string.h>
#define MAX 50

[Code]....

View 9 Replies View Related

C :: Enter Date - Calculating Next Day

Mar 14, 2013

Currently I am working on a program where you enter in a date 14 03 2013 (Day, Month, Year) and you get the next day. I seem to be coming stuck with months with less than 31 days, and the whole leap year thing. Here is my code so far.

Code:
#include <stdio.h>
int day, month, year, next_day, next_month, next_year, calculation;
int main() {
printf("Enter a date in the form day/month/year: ");
scanf("%d %d %d", &day, &month, &year);

[Code] .....

View 4 Replies View Related

C :: Remove Need For ENTER Key To Be Pressed

Jul 5, 2013

The following 2 codes are almost identical, only that the switch statements are slightly different. The 2nd code has the issue of requiring an additional enter key to be pressed when I enter '3' as input to exit the program.

Working code :

Code:

#include <stdio.h>
#include <ctype.h>
#include <string.h>
void clearKeyboardBuffer() {
int ch;
while ((ch = getchar() != '

[code]....

View 7 Replies View Related

C :: Program That Will Allow A User To Enter Their Name

Jul 2, 2013

I am trying to make a program that will allow a user to enter their name, from this point, three options should be present for the user to choose, then from that point, two more options should be present. I have if else statements in a switch case and I get the "undeclared" error for the a in the first " if(specificage == a) ".

NOTE: I use Code::Blocks.

Here is the code:

Code:
#include <stdio.h>
#include <string.h>
int main(){
char name[50];
char ageclass[50];
char specificage[50];

[Code] ....

View 3 Replies View Related

C++ :: Can't Enter Phrases In Loop

Jul 25, 2013

getline is not readable after first time through loop. It skips that line and goes to Do you want stop entry? line.

#include<iostream>
#include<string>
#include<cstring>
#include<cctype>
using namespace std;
void upr(const string& str);

[Code] ....

View 9 Replies View Related

C++ :: Enter Manually A Path?

Jan 26, 2015

about putting manually a path in my code.

This is what my code should looks like

#include <iostream>
#include <fstream>
#include <vector>

[Code]....

View 2 Replies View Related

C++ :: End Program By Pressing Enter Key?

Feb 11, 2014

I'm trying to end my program when the user presses the enter/return key.

I'm trying to do this with a break statement.

I have two different situations, one when it is a string, and the other one when it is a char.

for (int i = 0; i < 80; ++i)
{
string s;
cin >> s;
if (s == "
")
break;
S.PushStack(s);
}

I'm doing the same thing for char just replacing string with char.

I'm not sure what I am doing wrong but pressing enter does not end the program.

View 3 Replies View Related

C/C++ :: Breaking The Loop With Enter?

Feb 26, 2015

i just want to break the loop when user hit ENTER.But after that programm is stil working, i don't know why, becouse i have a code just like in book, i spend a lot of time with it.

int getinfo(student pa[], int n){
cout << "START" << endl;
int i = 0;
for(i; i < n; i++) {
cout << "Studetn name";
char name[SLEN];

[code].....

View 2 Replies View Related

C/C++ :: Using Pointers To Enter Data?

Nov 6, 2013

I want to do simple program to capture some 5 surnames of people(employees) - using array and pointers. Well I understand a bit of arrays and I know how to loop through.

How can achieve this? This holds the key to my understanding how pointers work and can be used with char or strings.

View 2 Replies View Related

C :: Selection Menu With Enter Key Support

Apr 27, 2013

I am working on a database project, which can store (initially) 10,000 marksheets with following capabilities

1) new entry
2) edit/modification of entry
3)delete entry
4) separate Departements ( BBA, BCS, M.Phil, Phd., etc.)
5) can store data on files ( initially, all data is stored in a single file)

Now, I want to create a menu, in which i can use arrow keys to navigate through the menu and use Enter key fo selection.

What should i use in it?? The project is only on C language.

View 4 Replies View Related

C :: Way To Sort As Enter Data Into Llist

Oct 19, 2013

Code:

struct lnode *ins_llist(char *data, struct llist *ll){
struct lnode *p, *q;

fprintf(stderr, "Data is %s when first entering ins_llist loop.
", data);
q = malloc(sizeof(struct lnode));
if ( q == NULL )
return(NULL);
}

[code]...

Trying to figure out a way to sort as i enter my data into the llist. What is in red and blue is what I've been messing around with to try and see if maybe i can get it to sort but it is not. When i flip sign, the order changes opposite, but i cant see how to sort each item as i go. Maybe i am too tired right now, lol, been working on this program for what feels like 30 of the past 24 hours haha.

View 2 Replies View Related

C :: Enter 10 Positive Numbers In Array

Nov 3, 2014

I have task to make program.. To enter 10 positive numbers in an array. Find three numbers that stand near each other and that have the maximum sum.

I understand how to make array, enter 10 number i find only one biggest number from 10.. How to find three max number sum that stand near each other..

View 10 Replies View Related

C :: What Will Happen If Enter A Char Instead Of Integer

Aug 21, 2014

Consider below statements:

int x;
scanf("%d", &x);

After running, It's supposed to enter an integer for x. what will happen if I enter a char instead of integer? which value will be in &x and x itself? I have a script and I get strange result while entering a char instead of integer for x.

View 5 Replies View Related

C :: Program That Allow To Enter Certain Amount Of Values

Sep 29, 2014

How to write a code that will let me input how many variables I want.

Write a program that will enable you to enter a certain amount of values

Eg. 4

And then add the corresponding integers. Ex.

Choice: 4 12 34 56 78

The sum of the integers is: 180.

View 4 Replies View Related







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