C++ :: Adding Entry Into Array?

Aug 6, 2014

My program is suppose to be as a virtual phone book that allows you to add,search, display names and numbers.

At the beginning you are able to add up to 10 entries and then from there the program goes to a menu where you can add more entries, search etc.

My problem is that I am unable to add an entry into the existing list of names/phone numbers.

Example: At the beginning I add Joe,Albert,Barry. It sorts them into Albert, Barry, Joe (good so far!)

However, if I choose to add another entry (Carl) it becomes Barry,Carl,Joe.

The functions I am using to add entries are: GetEntries (for initial entries) and Addentries for more entries during the main program.

*******************************COPY OF CODE**********************************

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

[Code].....

View 5 Replies


ADVERTISEMENT

C++ :: Adding Entry To Map?

Feb 5, 2013

I have the following code in sourceFile.cpp. functionA() is first called and inserted entires for key1, key2 and key3. Then functionB() gets called to use the vectors for the 3 keys. I want to free all memory after exiting functionC(). Among the three ways to put an entry into the map for the 3 keys, which is correct / better?

Class ClassA { ... }
ClassA *key1 = new ClassA();
ClassA *key2 = new ClassA();
ClassA *key3 = new ClassA();

[Code]....

View 2 Replies View Related

C++ ::  Passing A Polymorphic Array Entry

May 31, 2013

I'm having an issue during the linking stage of the .exe during compile time, and it's because of a call to a function with a polymorphic parameter.

//here's how the classes are setup
class grandpa {};
class mom public grandpa{};
class dad public grandpa {};

[Code]....

dad has sons in the vector and mom has daughter in the vector. What I want to do is have a function that can accept either of these vectors as one parameter like so: void func(const grandpa* aObject);

Finally, I have an error when I pass an object to the function like so: func( d[0] );

View 1 Replies View Related

C# :: How To Add Data Entry List In Array

Jan 29, 2014

I'm learning C# and having fun and I've been practicing by working on this little data entry console application. Basically the user inputs first name, last name, age, gender, employee id, then I ask the user if he/she wants to add another entry, if yes then loops back at the top, and if no, it prints out the amount of entries added. The issue I'm having is that the entry list is never kept or stored when adding another entry, it replaces what was entered before which is not what I'm looking for. I don't know how to stuff one entry list information seperately in an array so that I can print out which ever entry the user decides to choose once he/she is done adding entries. Is there a way to make this work?

Here is my program code:

using System;
namespace Ch02_Exercises_12
{
class Program {
static void Main() {
string firstName;
string lastName;
string input;
sbyte age;
char gender;

[Code] .....

View 4 Replies View Related

C++ :: Adding Each Value From Array?

May 21, 2013

How would one add each value from an array? I'm working from a string but I was wondering if there was a way to loop through the string and add each value. This is what I have so far:

#include <iostream>
#include <cmath>
#include <string>
int main() {
std::string numbers;
int sum;

[Code] ....

View 3 Replies View Related

C :: Adding Prefixing Array

Sep 28, 2013

I am trying to convert a string Input by user into an unsigned byte array.The data would be in hex form like :- "AE 1F 2C". I am thinking of using strtok to split the string into be " ". and then cast to (unsigned char *) . But for that I''ll have to prefix every element with 0X Is there any convenient way and elegant way to do this?

View 3 Replies View Related

C++ :: Adding Array Elements Together?

Sep 28, 2013

I'm having trouble getting my array to add its values together. I have a similar program running fine with the exact same equation. I am not so naive as to believe that this means it should run with every program but I'm at a loss as to what to do.

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

[Code].....

View 2 Replies View Related

C++ :: Adding Big Number Into Array

Jun 28, 2013

When i run the program i want to add a big integer number into an int array. How can i do it.i don't want to use for loop.

View 4 Replies View Related

C++ :: Adding New Record To Array?

Feb 1, 2013

I'm having some issues with adding a record to my array.

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

[Code].....

View 2 Replies View Related

C# :: Adding To Array From Different Class

Jan 10, 2015

I have an inventory array in a class called inventory. This class is in a different program. How do I access and add to this array for my main program?

View 1 Replies View Related

C++ :: Adding Up Elements Of Two Dimensional Array?

Jan 9, 2015

This code shows a loop inside a loop initializing a two-dimensional array named arr with elements [2] and [5]. Here's my code:

Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main ()

[Code]....

Now, what I wanted to do is to have an output showing the sums of each elements. Example, the above code has an output of:

1 2 3 4 5
6 7 8 9 10

I wanted to have more codes which would add up the elements 1 + 6, 2 + 7, 3 + 8, 4 + 9, 5 + 10 and produce and output:

7 9 11 13 15

View 8 Replies View Related

C :: Adding Chars From File To Array

Jan 29, 2014

lets say we have a txt that contains this

| | | | |*| |
| | | |*| | |

and that symbolizes a 2x6 char array and we want to take only the symbols inside the || and place them in a 2x6 char array. how do we do that?

View 1 Replies View Related

C :: Adding Elements To Array Of Structs

Mar 6, 2015

I have a structure product_array *pa that contains a pointer *arr to an array of structs and count that adds 1 when a new product is added (set to NULL initially). I have to write a function which adds a new product entry to that array. One product entry has *title, *code, stock and price parameters. The array is dynamically allocated and I’m supposed to:

1. Reallocate space for array.
2. Update product_array.
3. Initialize it.

Also, code should be truncated to 7 characters.Products can be added multiple times, so the initial size is unknown.

Code:

void add_product(struct product_array *pa, const char *title, const char *code, int stock, double price)
{
for (int i = 0 ;; i++){
pa->arr = realloc(pa->arr, sizeof(struct product_array));

[code]....

View 3 Replies View Related

C++ :: Adding-up Elements Of Two-Dimensional Array?

Jan 9, 2015

I would just like to share my code and wanted to do something about it. This code shows a loop inside a loop initializing a two-dimensional array named arr with elements [2] and [5]. Here's my code:

#include <iostream>
#include <conio.h>
using namespace std;

[Code]....

Now, what I wanted to do is to have an output showing the sums of each elements. Example, the above code has an output of:

1 2 3 4 5
6 7 8 9 10

I wanted to have more codes which would add up the elements 1 + 6, 2 + 7, 3 + 8, 4 + 9, 5 + 10 and produce and output:

7 9 11 13 15

View 5 Replies View Related

C++ :: Recursive Adding Elements In Array?

Mar 9, 2014

The goal of this program is to take 4 neighboring elements in an array and add them together. The program asks user for the number of rows and columns to start out with and the program will then continue to print the board until 1 element remains.

I'm having problems getting my program to compile (line 19)

#include <iostream>
#include <cstring>
#include <cstdlib>

[Code].....

View 3 Replies View Related

C++ :: Adding Char Array With Macro?

Dec 30, 2013

The book uses this example:

#define ALLOCSIZE 10000 /* size of available space */
static char allocbuf[ALLOCSIZE]; /* storage for alloc */
static char *allocp = allocbuf; /* next free position */
char *alloc(int n)
/* return pointer to n characters */

[Code] ....

The logic here I don't understand:

if (allocbuf + ALLOCSIZE - allocp >= n)

allocbuf is a char array allocated with 10000 positions. We add that to ALLOCSIZE macro which is 10000. Does that return a value of 20000? If so, it doesn't make sense to do this because all we had to do was this:

if (allocbuf - allocp >= n)

That takes length of allocbuf which is 10000 and subtracts allocp from it. So if allocp is 1000 we are left with 9000 available slots. And we can use that to check if we have enough to allocate n elements.

View 5 Replies View Related

C :: Array Of Structs (adding / Deleting Elements To A File)

Sep 20, 2013

I want to write a program to record my neighborhoods's name and address by using an array of structs and file.

my array of structs is

Code:
#define SIZE 30
typedef struct{
char name[30];
char address[100];
}Detail;
Detail neighbor[SIZE];

And I want to make adding,deleting, and searching functions.Something like

Code:

void add();//Add name and address to a file,
//and add more to the same file if I want to.
void del();//Delete or Change some neighbor's name or address
//in the same file(Can I?)
void search();//Search name and show detail

So I started to code adding function first, but I don't know that I need to use pointer to code each functions relations, and I don't know how to check that my input's already exists yet. But I started some code below...

Code:
void add() {
int i=0;
FILE *fp = fopen("neighborhood.txt", "at");
if ( fp != NULL ) {
do{

[Code]......

View 8 Replies View Related

C# :: Fibonacci Series - Adding Value In Array Inside While Loop

May 27, 2014

I am making a program to run Fibonacci series. I have created 2 array.

1)- 1st array holds only 0, 1
2)- 2nd array holds other values eg: 1, 2, 3, 5..........etc

I am using while loop to get the febonacci series and storing it in a 2nd array called int[] numbers.

After getting value using while loop, I am joing both the arrays using int[] final = arr.Concat(number).ToArray();

At last, I have used foreach loop to add the febonacci series into the listbox.

The problem I have is that, I cannot able to concat both the arrays. I tried to assign number array at the top of the while loop. so that number variable will be accessible outside the while loop. But I am getting a error.

See the code below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

[Code] .....

View 4 Replies View Related

C/C++ :: How To Create Entry Verification

Nov 21, 2014

I have an assignment to create a program that will display the duplicate numbers that were entered by a user. I have the code finished and I have covered the basic requirements of the assignment. However, during my testing I found that if I enter anything other than a whole number (i.e. char or float) the program will run out and exit. I would like to add a little code to verify that the user has entered a whole number. I cannot seem to get this to work though. I have written other codes that verify if a number is above and below a certain value, I just do not know how to look for a certain type of entry.Here is my code:

int main() {
int number[20];
int duplicateNumber[20];
int i, j, k, counter = 0;
// Get number input from the user
for (i = 0; i < 20; i++) {
printf("Please enter a whole number %d: ", (i + 1));

[Code]...

View 3 Replies View Related

C++ :: Displaying Average For Each Entry

May 3, 2013

I have to display an average for each student that is entered ....

void StudentData::displayAverageScore() {
double totalScore = 0;
double totalEx1 = 0, totalEx2 = 0, totalEx3 = 0, averageScore = 0;
for(int i = 0; i < entries.size(); i++) {
totalEx1 += entries[i].getEx1();// accumulate totals
totalEx2 += entries[i].getEx2();
totalEx3 += entries[i].getEx3();
if(totalScore != 0) averageScore = (totalEx1 + totalEx2 + totalEx3) / 3; // don't divide by 0
cout << "Average Score For Exams: " << setprecision(1) << fixed << averageScore << endl << endl;
}
}

View 7 Replies View Related

C++ :: Makefile Only Executing First Entry

Mar 15, 2013

Why this makefile only executes the first entry, compiling only the first program listed?

###########################################################
#
# Simple Makefile for Operating Systems Project 2
#
###########################################################
vowcon:
g++ -o vowcon vowcon.cpp -pthread
osproj2c:
g++ -o osproj2c osproj2c.cpp -pthread
osproj2b:
g++ -o osproj2b osproj2b.cpp -pthread
osproj2a:
gcc -o osproj2a osproj2a.c -pthread
clean:
rm osproj2a osproj2b osproj2c osproj2d vowcon

View 7 Replies View Related

C/C++ :: While Loop To Stop After Third Entry

Jul 6, 2014

Having multiple issue trying to get a while loop to stop after the third entry.

#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
int mySequentialSearch() {
int value;
string line;

[Code] .....

I am just working on the while loop right now. Then the function after I get the loop working.

View 10 Replies View Related

C :: Secure Entry Keypad Simulator

Feb 15, 2015

We've been tasked write a code which would mimic a secure entry keypad.. Only recognising the digits 0-9 for the passcode, and non-numerics S (start again) C (clear last digit) and E (enter) for the control. All other key strokes are to be ignored.

The passcode has to be <10 digits and represented on the screen by "****", with any keystrokes >10 ignored.
The valid passcode being 4 digits (1234).

With 3 attempts to get the correct pass code, after each fail attempt as please try again message show, where after the 3rd attempt a specific message is displayed and an alarm sounds..

View 13 Replies View Related

C :: The Last User Entry In Loop Fprintfed Twice?

Apr 13, 2014

Still working on my first homegrown C program design . The function basically allows the user to enter a list of classes and grades and saves the list to a file to be used later in the file. The function compiles and runs through without error except for the fact that it always prints the last user entry to the *profilep file twice. Just as a note, the scanchar function is one I made to scan in one character and an end of line character to throw away the end of line char before I learned about %*c about 30 minutes ago...

Also I haven't much bothered to strengthen the function against crazy user input but I have heard using fgets and sscanf in conjunction can replace scanf and protect against weird user input. How to apply this within the program.

Code:
// creates a new profile and prints it to the profile file.
void newprof(FILE* profilep, const char *allclasses[ABBR_SIZE]){
int c, checker, counter;
int i, a;
char prof[MAX_PROF][ABBR_SIZE];
char grades[MAX_PROF][3];

[Code] .....

View 1 Replies View Related

C++ :: Error 453 - Can't Find DLL Entry Point

Nov 7, 2013

Using VC++ 2010 Express. I am creating a dll to export a simple Multiply function so I can use it in Excel/VBA

These e are the steps I am following :

. Create a Win32 C++ Project and give a name. For example: CallDllFromVBA
. Select the DLL option in the Wizard and click Finish
. In the CPP file (here CallDllFromVBA.cpp), add the following code

#include "stdafx.h"
int _stdcall Multiply(int x, int y) {
return x * y;

[Code] ....

The Build output show everything is ok as follows :

CallDllFromVBA.cpp
CallDllFromVBA.vcxproj -> c:documents and settingsadministrateurmes documentsvisual studio 2010ProjectsCallDllFromVBADebugCallDllFromVBA.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

In VBA, I insert a module and add the following code:

Declare Function Multiply Lib _
"c:documents and settingsadministrateurmes documentsvisual studio 2010ProjectsCallDllFromVBADebugCallDllFromVBA.dll" _
(ByVal x As Long, ByVal y As Long) As Long
Sub test()
MsgBox Multiply(2, 4)
End Sub

When I run the Test sub I get the error: 453 - Can't find dll entry point

I also opened the CallDllFromVBA dll with Dependency walker and I can't find the Multiply export function - In fact, the dependency walker doesn't show any function exports at all for the CallDllFromVBA dll !

View 2 Replies View Related

C/C++ :: Conditional Multiple Entry Points?

Nov 16, 2014

I'm playing with my final year project, building a game boy emulator in C, and I wanted to try out something to streamline my code base. I'm building against Win32, GNU C and Googles Native Client.There are no platform specific headers or functions in use. What I'm trying to do is have a file that conditionally includes the entry point (so _tmain for Windows etc) based on a preprocessor directive being set/not-set.

[note] I realise I could write both entry point classes in one file and use the preprocessor directive in there, but it's not as neat as a single file calling in one or the other. I figure this should work because I can conditionally include headers for Win/NaCl (providing the signatures match, of course).

View 3 Replies View Related







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