C++ :: Declaration Of Variable To Hold A Table Of 5 Records

Aug 27, 2014

im doing a program to store name, age, time and fitness. and i need to hold a table of 5 such records.can i do this?

#include <iostream>
using namespace std;
int name1, age1, time1, fitness1;
int name2, age2, time2, fitness2;
int name3, age3, time3, fitness3;
int name4, age4, time4, fitness4;
int name5, age5, time5, fitness5;

[code].....

View 3 Replies


ADVERTISEMENT

C# :: Increment Records By 1 And Update In Table?

Jan 27, 2014

This is my code as following

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

[Code]....

I have driver table this is my fields as following
DriverID INT
DriverName nvarchar50
Nationality nvarchar50
Address nvarchar50
I have form driver have 4 texbox
textbox1 DriverID
textbox2 DriverName
textbox3 Nationality
textbox4 address
this table have two records

when i press buton next (NextBtn_Click)to go third record it not accept I need next button increase by 1 if record not exist and update this in table How i do this example if i have two records

1 aln american newyork
2 adam british british

when i press next button it ok work in records exist but when i press next button to third record it not accept why what i need is when press next after 2 it come 3 in text box driver id and update this number in table

View 1 Replies View Related

C++ :: Variable That Can Hold String And Int In Same Time?

Feb 12, 2014

Is there a variable that can hold string and int in the same time?

If not, what can I do if I want to input data with string and int like a password for an example.

View 3 Replies View Related

C++ :: Hold Group Of Variables In One Variable

Oct 4, 2014

So far i know that the pointer is address value to the real variable. Pointer size depends on operation system right?

for example
32bit systems: 4byte pointers
64bit systems: 8byte pointers
128bit systems: 16byte pointers?

Anyways, there have to be an variable type in c++ what can hold a pointer.

Let's imagine that the int is the thing im looking for

struct stc1 {
char *chars;
int ints;
}
struct stc2 {
char *chars;
float floats;

[Code]....

My wish is to hold different types of variable or groups of different type of variables in one variable.

I am developing program in windows now yet it will be used in linux and who knows with what x bit systems.

View 2 Replies View Related

C :: Declaration And Definition Of A Variable

May 11, 2013

I read that Memory is allocated during definition of a variable and not during declaration. Declaration is something like,

Code: int x;

And definition is assigning some value to it. This is what my professor taught. My doubt is if memory is not allocated during declaration, then how the compiler successfully compiles and runs the following, which i had already tried.

Code:
#include<stdio.h>
#include<conio.h>
int main() {
int c;
int *p=&c;
printf("%x",p);
getch();
return 0;
}

The variable c is only declared. But the program outputs a memory address. Shouldn't it show an error?

View 2 Replies View Related

C++ :: Static Variable Declaration

Oct 4, 2014

If i declare 2 variables like this static int first, second; will both of them be declared static or will only first be declared static and second a regular variable?

View 5 Replies View Related

C++ :: Class And Variable Declaration?

Aug 2, 2014

#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class ir;
class Bank_acc {
private:
string name,type,s;
long int accno,temp,balance,in;

[Code]....

errors are:

|6|error: forward declaration of 'class ir'|
|54|error: invalid use of incomplete type 'class ir'|
|99|error: no matching function for call to 'ir::interest()'|

View 1 Replies View Related

C :: Declaration And Definition Of External Variable

Jan 11, 2014

Why I take warning on this code :

Code:
#include<stdio.h>
extern int v = 0; // Declaration and definition of an external
int main(void)

[code]...

Is there any error? Why I take a warning: 'v' initialized and declared 'extern'|||=== Build finished: 0 errors, 1 warnings ===| ???

and what is the meaning of :An extern declaration that initializes a variable serves as a definition of the variable. This rule prevents multiple extern declarations from initializing a variable in different ways.

View 3 Replies View Related

C++ :: Access Variable From Other Scope Without Global Declaration?

Aug 8, 2013

Code:
#include <iostream>
using namespace std;
void f() {
int x=17;
//cout<<main::y<<endl; i want to access y from main scope
}

int main() {
int y=23;
//cout<<f::x<<endl;

I want to access x from f scope is there any way for this without global declaration? specially about function scopes...

View 1 Replies View Related

C++ :: Difference Between Variable Declaration Inside And Outside For Loop

Sep 10, 2013

What is difference (memory allocation or any) between declaring a variable inside or outside the variable

program1:

#include<stdio.h>
int main() {
int i;
for (i=0;i=<100;i++) {

[Code] .....

Difference b/w program1 and program2. Its look both are same. but my compiler shows something difference.

View 1 Replies View Related

C++ :: T Minus Loops - Variable Index Declaration

Apr 25, 2014

(while)

T minus 10 and counting
T minus 9 and counting
T minus 8 and counting
T minus 7 and counting
T minus 6 and counting
T minus 5 and counting
T minus 4 and counting
T minus 3 and counting
T minus 2 and counting
T minus 1 and counting

Declare the following index before the while loop:

int index = 10;

Correctly code a while statement below using the variable index as defined above, to produce the output shown above.

So this is what my code looks like... I also have to convert this same loop into a do while and for loop. So if I can get this one right I think the others should come relatively easy.

while (int index >= 10) {
cout << "T minus " << index;
index--;
}

View 4 Replies View Related

C/C++ :: Local Variable Declaration - While Loop Expression

Feb 3, 2013

I got the following lines of code from a book. The variable char c is being used here to demonstration local variable declaration.

  while(char c = cin.get() != 'q') {
    cout << c << " wasn't it" << endl;
    if(char x = c == 'a' || c == 'b')
      cout << "You typed a or b" << endl;
    else
      cout << "You typed " << x << endl;
  }

It compiles and runs. There are two issues when I try to run it.

1) It seems to loop through two times for every entry. If I insert cin.ignore() just before the closing bracket, it seems to work better.

2) the variable c does not seem to have the character I entered when examined in the if statement.

What is happening with the variable c inside the while loop scope?

Does c actually get initialized?

View 2 Replies View Related

C :: String Declaration As Global / Main Local Variable

Nov 14, 2013

When a declare a string e.g.

Code:
char str[30]; as a global variable, the srting is initialized to NULL.

But if I declare char str1[30] INSIDE main(), then the string has garbage inside.... Why this happens??

E.g. the following code snippet...

Code:
#include <stdio.h>
char str[50];
int main(){
char str1[50];

[Code] ....

View 4 Replies View Related

C :: How To Initialize Variable Word In Separate Statement From Its Declaration

Aug 7, 2013

I wrote the following program to initialize a string after the variables is declared, but it isn't working. A warning is given by the compiler, and the execution of the program shows a strange string. How do I initialize variable word in a separate statement from its declaration?

Code:

#include <stdio.h>
int main( void )
{
char word[20];
*word = "Hello";

printf( "The string is %s.
", word );
return 0;
}

View 3 Replies View Related

C++ :: Variable Declaration (const Pointer To SensorBase Object)?

Feb 19, 2015

I'm having to do a little c++ (coming from java) and don't understand the syntax of the following declaration

Code:
SensorBase* const sensor(mSensors[i]);

It looks like it's declaring a const pointer to a SensorBase object but I don't understand how that applies to sensor(mSensors[i]) which looks like a function??

View 6 Replies View Related

C++ :: Object And Classes - Declaration Of Variable Using User Defined Type

Mar 17, 2013

I am getting a compilation error from the code below. It is when i am naming a variable with my user defined type.

#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
class person {

[Code] .....

C:Dev-CppTRIAL.PASS.!!!.cpp In function `int main()':
66 C:Dev-CppTRIAL.PASS.!!!.cpp expected primary-expression before "p"
66 C:Dev-CppTRIAL.PASS.!!!.cpp expected `;' before "p"
74 C:Dev-CppTRIAL.PASS.!!!.cpp `p' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
83 C:Dev-CppTRIAL.PASS.!!!.cpp `X' undeclared (first use this function)

View 4 Replies View Related

C++ :: Table Of Variable Size?

May 10, 2014

I would like to create a table but I dont know how big. Thats why I want to use variable to describe its size. Something like that:

int x = 5; //I will use a function to set x
int Table[x];

What should I do to make it work?

View 4 Replies View Related

C/C++ :: Printing Table Of ASCII Chars - Cannot Initialize Variable

Apr 9, 2014

I'm trying to write a program which prints a table of ASCII chars, I'm not really done with my thoughts on it but I already
ran into the following error:

Error: cannot initialize a variable of type 'char' with an rvalue of type 'char (*)[16]'

Here's my code so far:

# include <iostream>
using namespace std;
int main() {
char asciiTable = new char[8][16];
int nextSign = 0;

[Code] .....

View 4 Replies View Related

C Sharp :: Search A Record In SQL Table Using Datetime Variable

Jan 1, 2014

I have an application in C sharp that searches for a record in a sql database using a datetimepicker,the output is displayed in a datagridview.When I execute it I got a blank datagridview with empty columns.I can not view the content and I don't get any error message.

Here is my code:

DataTable dt=new dataTable();
SqlDataAdapter sda=new sqldataadapter("select * from Delivery where convert
(char(20),Delivery_Date,112)='"+ dateTimePicker1.value.Date,con);
//con is sqlconnection
Sda.Fill(dt);
Datagridview1.DataSource=dt;

View 1 Replies View Related

Visual C++ :: Hash Table - How To Setup Static Variable

Apr 22, 2014

I am having trouble getting the cout statements that I commented out to work properly. And I can't figure out why the first movie in the movies.txt file displays at the end of the list in my output screen when it should only display once as the first item. I am also having trouble figuring out where and how to set up the static variable.

Purpose : This assignment requires that you to develop a program using the classes listed above. Specifically you will build a hash table containing movie data. The collision strategy will be to build linked lists as the array elements.

Program Specifications : Your program will read the data from the file named Movies.txt located in the StudentFiles1.zip file on the Connections Portal. Each record contains 2 fields separated by a space. They are:

FieldsData Type
Motion Picture Association Code (MPAC)Integer
Movie NameString

Your application program will read each record, create a Movie structure instance and place that structure instance into the hash table.

You will need to modify the appropriate code to provide for an audit trail of the hash table construction. To accomplish this, you will use cout statements in the above class member functions. You will need to modify them to include couts, but the modifications will be relatively small. If not, you are doing it wrong. The hashing algorithm to use is:

Index = int ( 0.618033 * MPAC) % size

Make the array size a constant and set it to 10.

Include a counter for the number of collisions that occurred in building the hash table. Including a static variable in the LinkedList or List class is the best method for doing that.

See the sample audit trail below for the first 5 records on Movies.txt and the size of the hash table set to 3. This is shown for illustration only. The full file will have different locations calculated.

1101-Casablanca is being added
The hashed location is 2
There was no collision loading 1101-Casablanca
------------------------------------------------
1200-Duck Soup is being added
The hashed location is 0
There was no collision loading 1200-Duck Soup
------------------------------------------------

[Code] ....

After the above is displayed, prompt the user to enter the MPAC of a movie to locate. Produce an audit trail when locating the requested movie as shown below: Make sure you list all movies that have collided at the hashed location. That may also cause you to modify one of the existing ADTs a little.

Will search for 6601
at the hashed location is 2
There was a collision here with 6601-Wizard of Oz
There was a collision here with 1101-Casablanca
retrieved from hash table: 6601-Wizard of Oz

[Code] ....

View 10 Replies View Related

C++ :: Hash Table Program - Sorting Pointer Table After All Of Values Entered

Nov 19, 2013

I am having an issue with my sort function. This is one part of the Hash table program. The main issue is that I am trying to sort the pointer table after all of the values have been entered. The ptr_sort function is not a class function and so I am therefore unable to use the class variables psize and pTable. Is there another way I should be trying this? it is a Vector should I use the sort() function from the vector class in STL?

#include "/home/onyuksel/courses/340/progs/13f/p9/util9.h"
#include "/home/onyuksel/courses/340/progs/13f/p9/hTable.h"

#ifndef H_TABLE1
#define H_TABLE1
void ptr_sort ( );

[Code] ....

View 1 Replies View Related

C++ :: Truth Table Generator - If User Enters String Of Boolean Algebra It Will Output Table

Jan 25, 2013

If a user enters a string of boolean algebra it will ouput the table.

I have input parsing, cycling through the combinations, and outputing working. However once i parse the input I am not sure what to do with it. I have thought of having it write the parsed input to a new file as a function and then use that function, but that seems bad.

How to dynamically create the function, how to implement it.

BTW This is a console function, if that changes anything.

View 2 Replies View Related

C# :: Lookup Non-existent Rows In MySQL Table And Then Update Another Table

Dec 15, 2014

I have written an SQL statement that would:

1) Count the number of rows in the table booking that are open and where the booking.postcode is "MK",

2) Take a note of the plot (in booking.plot_id), and then update the table plot.jobs with the value count.

For example running the SQL query when booking table has the following rows:

Would see the following highlighted values in plot.jobs being updated to 1:

I managed to resolve it with this code so far (note I am using Connector/Net):

public void RefreshPlot(){
string query =
"SELECT Count(*) AS count, plot_id FROM booking WHERE postcode='MK' AND status='open' GROUP BY plot_id";
var cmd = new MySqlCommand(query, _connection);
var da = new MySqlDataAdapter(cmd);
var dtCounts = new DataTable();
da.Fill(dtCounts);

[code]....

Currently, my code only checks for existing rows in the booking table and updates the plot table. However if the row gets deleted in the booking, then the changes are not reflected in the plot table.

Example: If we delete the row with plot.id=1 and plot.plot_id=4, then booking.plot_id should go back to being 0, if it was initially 1. At the moment, it doesn't. How would I update my SQL statement to better reflect this? In a sense, it should check for "non-existent" rows, i.e. the impact that the row plot.plot_id=4 & plot.id=1 has on booking.plot_id when deleted?

View 6 Replies View Related

C Sharp :: Copy Data Table To MySQL Table

Mar 25, 2013

I have a C# .NET Application which get data from QuickBooks via the ODBC Driver and save the result to C# data table. So, I want to transfer this data table to a mysql table on my own server. That's the code I use:
 
using System.IO;
using MySql.Data.MySqlClient;
//Add mysql dll on the .NET Tab in Project's references  
string connStr = "DSN=QBTest;";  
            string myServerAddress = "192.168.0.243";
            string myDataBase = "CostTest";

[Code] ....

View 2 Replies View Related

C++ :: SDL - Check For A Key That Is Hold Down?

Sep 13, 2013

I'm using SDL to try to create a Run and Shoot game. But I do not know how to check if a key is down while the user is HOLDING it.

I do know how to check if a key was pressed.

I have tried with the "event.key.keysym.sym" and "Uint8 *keystate = GetKeyState(NULL)" both worked to check if a key was down but I thought that the GetKeyState(); Function would even check when a key where HELD down

I want my player to move while holding down left or right arrow. So I did something like:

Code:

Uint8 *keystate = GetKeyState(NULL);
if (keystate[SDLK_RIGHT]) {
apply_surface(x++, y, player, screen);
}

How to check if a key is held down?

View 2 Replies View Related

C# :: Use Table Adapter With Textboxes To Edit SQL Table?

Mar 8, 2015

I am a bit stumped with trying to write some code to get the tableadapter/binding source to "update" a current 'user' to the table.

I have the insert/delete methods working fine, but it's the updating that has got me screwed up.

Example of insert.

try
{
personTableAdapter.Insert(tFirstName.Text, tSurname.Text, Convert.ToDateTime(tDoB.Text), tPhone.Text, tAdd1.Text, tAdd2.Text, tSuburb.Text, tState.Text, tPostcode.Text, TeacherType.Text);
teacherTableAdapter.Insert(Convert.ToInt32(tTID1.Text), tRegNo.Text, tPassword.Text);

[Code]....

I also tried to do the updated string/original string with the tableadapter.update, but that didn't work either.

View 7 Replies View Related







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