C/C++ :: Tables Initiated With Pointers

May 23, 2014

In my code I have lots of structures. I try to make tables of structures and then get access to elements of the structures to use them all along my code: here is an example to clarify things

typedef struct {  
Fabric **closfabric;  
}Network;  

Net is part of another structure called Switch and Fabric itself is a composed structure. I have done the following

aSwitch->net.closfabric = (Fabric **)malloc(3* sizeof(Fabric *));  
aSwitch->net.closfabric[0] = (Fabric *)malloc(m * sizeof(Fabric ));
aSwitch->net.closfabric[1] = (Fabric *)malloc(k * sizeof(Fabric ));
aSwitch->net.closfabric[2] = (Fabric *)malloc(m * sizeof(Fabric ));  

The compilation returns a segmentation fault because aSwitch->net.closfabric is NULL (0) .

Surprisingly, in other codes the same analogy of using tables made of double pointers works perfectly with no problems and I have no problem of core dumped and NULL pointers.

Why am I getting this problem. It is the case whenever I try to use large dimension tables (tab *** struct for example)...

View 2 Replies


ADVERTISEMENT

C++ :: Hash Tables And Queues

Jun 3, 2013

For my homework I need to create a hash table with a size of 7. I also need to create a queue that holds 3 names maximum for each table position

View 1 Replies View Related

C/C++ :: Run Basic Stats On 150 Tables

Mar 7, 2014

I need to run some basic statistics on about ~150 tables that are currently in dBase format. Rather than use excel to do them all individually, i was told to use s+ and write a code to loop through them, but I have never written any code and my experience with spotfire s+ is limited (the stat software i have available) ....

View 4 Replies View Related

C++ :: Program To Display Multiplication Tables

Feb 8, 2014

I have to write a program to display multiplication tables. I have written the following code:

Code:
#include <iostream>
#include <cstdio>
using namespace std;
int main(){

[Code] ....

View 2 Replies View Related

C# :: Update Multiple Tables In One Query?

Jul 23, 2014

i'm trying to update multiple table values with same column using one query.

Here's what i've tried so far:

mySql.CommandText = "Update tbl_employees,tbl_emp_additional_info,tbl_allocated_deductions,tbl_benefits,
tbl_cashadvances,tbl_deduction_history,"+
"tbl_dtr,tbl_empabsences,tbl_empstatus,tbl_otherdeductions
,tbl_ots,tbl_payroll_history,tbl_rdcomments,tbl_reversed_deductions,tbl_reversed_deduction_paid "+
"set tbl_employees.emp_id=@newemp_id,tbl_emp_additional_info.emp_id=@newemp_id,tbl_allocated_deductions.

[code]...

I've also tried removing all the other "and" operators but still no luck.It doesn't throw in exception yet it doesn't update my tables column values.

View 14 Replies View Related

C++ :: Five Different Tables - Array Sort Exception Return

Dec 18, 2014

I am creating 5 different tables each one has 20000 more elements more than the previous when i try to sort them with the sort algorithm quick sort for the first table tha has 20000 elements runs grate then it throws this exception how is this fixable ?

Exception : terminate called after throwing an instanceof 'std::bad_alloc' this application has Requested the Runtime to terminate it in an unusual way. Please contact the applications's support team for more information. Process returned 255(0xFF) . here is the code that gives this return :

Code:
#include<time.h>
#include<stdlib.h>
#include <string.h>
#include <ctime>
using namespace std;
int * Create_Table(int table[],int N);

[Code] .....

View 10 Replies View Related

C++ :: Enter A Value And It Will Return Corresponding Correct Answers From Tables

Dec 17, 2013

Currently I have to manually look up values on several different tables in different locations. I have 8 or 10 tables with 100 to 500 parts.

I would like to write a program so if I enter a value it will return the corresponding correct answers from the tables.

If I entered 2.5 for a value it would return the following three items from the tables since they all meet the requirement.

Table 2
Part min max
235 2.4 2.9

Table 6
Part min max
589 2.3 2.5

Table 7
Part min max
12 2.3 2.7

What would the best method be for setting up and accessing tables like this? Is C++ good at representing something like this or should I be looking at a different language?

View 3 Replies View Related

C# :: Join Tables In LINQ With Lambda Expressions

Dec 5, 2014

i have stuck in a join and i cant figure out where the problem is, i have those tables

public class Themes
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }

[Code].....

View 12 Replies View Related

C# :: Javascript Data Tables Not Showing On Page?

Nov 10, 2014

The problem is that the data table doesn't show at all. Here is the code:

<%@ Page Title="" Language="C#" MasterPageFile="~/LB/MasterPage.master" AutoEventWireup="true" CodeFile="InsertedInfo.aspx.cs" Inherits="LB_InsertedInfo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

[Code]....

View 5 Replies View Related

C# :: Using Info From MySQL Tables And Referencing Results

May 8, 2014

Basically I have a few tables in my Database.

So I have one table that is like so:

Item_ID, Name, Parent ID.
1 , jeff , 5

and another table like this:

Parent_ID, parent_Name
5,jackson

What I would like to happen, when I run my code is that I'll get the following

Item_ID, Name, parent_Name
1 , jeff , jackson

DataSet DS = new DataSet();
if (this.OpenConnection() == true) {
mySqlDataAdapter = new MySqlDataAdapter("select Item_ID, NAME, Parent_ID from table1, table2", connection);
mySqlDataAdapter.Fill(DS);
dataGridView1.DataSource = DS.Tables[0];
//close connection
this.CloseConnection();
}

So this spit out parent ID = 5.

I've not worked with Dataset before and I was just wondering what is the best approach? Can this be done via a SQL command or will I have to replace the value(5) with the string(jackson) using a large IF loop to search and replace.

View 1 Replies View Related

C++ :: Radix Sort Not Working - Implementation Using Two Tables

Jun 13, 2014

I'm trying ultimately to do a radix sort. I'm going with the implementation using two tables. One will initially hold the unsorted values then hold the partially sorted values thereafter. The other will be an array of linked lists which will be where the radix sort is done. Here is my code thus far:

Main

#include <iostream>
#include <fstream>
#include "radix.h"
#include "radix.cpp"
using namespace std ;
int main ( int argc , char * argv [ ] ) {
ifstream input ( argv [ 1 ] ) ;

[Code] ....

It appears to be crashing during void insert_into_sorted ( int to_insert , int place ) ; and I'm not sure why.

View 2 Replies View Related

C Sharp :: Combining Multiple Access Tables Using C#

Aug 14, 2012

I'm having a bit of trouble with something. What I'm trying to do is create a new Access table by combining other already existing Tables.

For instance, let's consider Table1 (with columns A, B and C), Table2 (with columns A, D and E) and Table3 (with columns A, F and G), where Table1.A = Table2.A = Table3.A.

From these, I want to create a new table TableResult, with columns A, B, C, D, E, F and G, with all the data contained in them. There's one catch: I want the code to get the names of the other columns, apart from column A.

I've thought about using Union, but I need to actually create a new table by combining the previous tables.

View 11 Replies View Related

C# :: Link Multiple Tables In Crystal Report With Foreign Key

Apr 2, 2014

i have 2 tables with primary and foreign key

Customer Details

EID - Primary Key

PurchaseDetails

PNo-Primary Key
PDate,
EID- Foreigh Key
NetAmount

Report Query written in c#

SELECT DISTINCT P.PNo, P.PDate, P.PM, P.DisAmt, P.LT, P.NT, P.EID, P.PTime, C.EName FROM PurchaseDetails AS P INNER JOIN CustomerDetails AS C ON P.EID = C.EID

In Report Automattically linked based key.

but report data not showing

View 1 Replies View Related

C# :: Multiple Tables Conversion From Excel XLS File To XML With OpenXML

Apr 25, 2014

I have downloaded this project from here -->> [URL] ....

This one works fine and it's a great commented code to understand even for beginners like myself, but it only works with one table per sheet. Once I add second table in sheet, it throws an error that something is wrong in one of the columns in my spreadsheet: It says: " Error occurs! The error message is: Cannot find column 4. "

Basically, I have this type of tables in my spreadsheet:

So I want that my program would export those two tables in a single .XML file (just read them both). And those two tables should be separated in two XML childs: the upper one should be Order-Header and the lower one - Line-Items, like this:

<ROOT>
<Order-Header>
.....
</Order-Header>
<Line-Items>
.....
</Line-Items>
</ROOT>
ConvertExcelToXML.cs:

[Code] ....

I copied all the code because I think it is the easier way to spot where to change it, to read those two tables in one spreadsheet and export them both in one XML file. How could I achieve this kind of functionality.

View 14 Replies View Related

C# :: Entity Framework - Select Specific Column In Tables

Apr 28, 2015

I need to show in a comboBox thats shows infor from Entity framework but i need to select a specific colum in the tables..

All in C# visual studio xaml form

So I created a var but i get and output: name of programe.NLHEntities

using (var context = new NLHEntities()) {
var blog = context.EtagesChambres
.Where(b => b.TypeChanbre == "Prive")
.FirstOrDefault();
textBox2Type.Text = Convert.ToString(blog);// i put a text box to see what the output would be..
}

View 14 Replies View Related

C :: Create Array Of Pointers To Pointers Which Will Point To Array Of Pointers

Feb 28, 2014

I'm trying to create an array of pointers to pointers which will point to array of pointers (to strings) I tried

Code:

int i;
char *string[]={
"my name is dave",
"we like to dance together",
"sunny day",
"hello",

[code]...

the app keeps crashing , I don't know how to make the array-elements to point to another array-elements..

View 4 Replies View Related

C++ :: Comparing Char Pointers To Integer Pointers

May 21, 2013

I am a little confused while comparing char pointers to integer pointers. Here is the problem:

Consider the following statement;
char *ptr = "Hello";
char cArr[] = "Hello";

When I do cout << ptr; it prints Hello, same is the case with the statement
cout << cArr;

As ptr and cArr are pointers, they should print addresses rather than contents, but if I have an interger array i.e.
int iArr[] = {1, 2, 3};

If I cout << iArr; it displays the expected result(i.e. prints address) but pointers to character array while outputting doesn't show the address but shows the contents, Why??

View 2 Replies View Related

C++ :: Dynamic Creation Of Arrays Of Pointers To Arrays Of Pointers

Apr 15, 2013

I'm trying to write a function that takes a 32bit address and a data to store at this address.

I'm wanting to take the 32 bit memory address eg 0x12345678 and split it
into 4 x 2 bytes
12, 34, 56, 78

then each of the 4 entries is at most a 256 entry array.eg
FF, FF, FF, FF

So in this example, 0x12 points to 0x34 in the second array, which points to 0x56 in the third array, which finally points to 0x78 in the last array. This last array holds the actual data.

After successfully doing 0x12345678, say I might get a read for 0x1234AABB. So, the first and second pointers already exist, but I then have to create and write to dynamically created arrays.

The arrays need to have all entries set to NULL so that i know whether to follow the pointers to overwrite a previously entered value or create new arrays and pointers.

It all looks good and simple in the pseudo code I've written up but I'm having trouble coding it. I'm currently trying to deal with the first entry case, ie all array elements are NULL, but I'm getting confused with the pointers and creation of new arrays.

void cpu::store(unsigned int mem_add,unsigned int mem_val) {
int first = (mem_address&4278190080)>>24;
int second = (mem_address&16711680)>>16;
int third = (mem_address&65280)>>8;
int fourth= (mem_address&255);

[Code] .....

A1 has been declared as
int* A1[256] ;

View 3 Replies View Related

C++ :: When To Use Pointers

Apr 4, 2013

give me a few solid examples for when one should use pointers.

View 14 Replies View Related

C :: Gcc Compiler And Pointers

Mar 3, 2013

The first sample program that I am reading on the book has the following code:

Code:

* Demonstrates basic pointer use. */
#include <stdio.h>
/* Declare and initialize an int variable */
int var = 1;
}

[code]....

Is this a compiler error or is there a proper syntax for pointers using the gcc compiler?

View 3 Replies View Related

C++ :: Use Different Pointers For Arrays?

Dec 24, 2013

So when if you want to change the values themselves for example in an array (just for example) this is valid;

void test(int* test)
{
test[0] += 10;
}
int bob[] {1, 3, 5};

If you did that bob[0] would not equal 11. All well and good right?

Now if you do this?

int sally = 33;
test(sallay);

This wouldn't work at all you actually have to use

void test(int& test)
{
test += 10;
}

how the memory addresses etc. are working here? I don't understand why you need to use & the reference operator if it's not an array? Why wouldn't that still work?

View 3 Replies View Related

C++ :: Payroll Net Pay With Pointers

May 15, 2014

Alright, after what seems like forever I'm on the last stage of modifying my Payroll Program. This time I have to sort using pointers and I only have to sort the Net Pay category.

Using one of my earlier programs I've removed content from it until it's in a state where it runs but contains no sorting functions.

So now I've to a working program that lacks any kind of sorting and looks like this.

#include <iostream>
#include <fstream>//file input output stream
#include <iomanip>
#include <string>
using namespace std;
//function prototypes
int readalldata(long int id[], string fname[], string lname[], int hoursworked[], float hourlyrate[], int n);

[Code] .....

My hints for how to add pointers to the program are...

int *np,tmp;
for (i=0,i<n; i++) np=&netpay[i]; //associating the netpay to np;
temp=np[i];//storing the pointer to a temp

I've been fooling around trying to sort the Net Pay by pointers using these hints for a bit now and I'm still not getting it.

View 2 Replies View Related

C++ :: Set Pointers To Default Value For Both 32 Bit And 64 Bit

Sep 6, 2013

I have a problem. I want to set pointers to a default value for both 32 bit and 64 bit compiles. The 32-bit version works as:

enum constants { UNDEFINED = 0xDeadBeef }
if ((unsigned long)ptr == UNDEFINED)

but I can't seem to extend this to 64-bits. I've tried
#if __SIZEOF_POINTER__ == 4
enum constants { UNDEFDATA = 0xDeadBeef };
}; // enum constants
#elif __SIZEOF_POINTER__ == 8
enum constants { UNDEFDATA = 0xDeadBeefDeadBeef };
#endif

with:
if (ptr == UNDEFINED)

but get a message saying the '==' is undefined (I understand this)

Is there any way to setup so that I can change the size of my constants so that the comparisons will always work correctly? I've tried a 'typedef' but the compiler complains at

'typedef unsigned long long ADDR' // won't accept, and
static const SlipCellBase * const TEMPORARY = (SlipCellBase&)0xFFFFFFFFFFFFFFFF; // illegal conversion

enum doesn't work (because it's an int?)

View 1 Replies View Related

C/C++ :: Pointers And Structs

Dec 14, 2014

What the second print statement prints

main() {
struct s1{
char *str;
int i;
struct s1 *ptr;

[Code] .....

I executed the code and the output was some number(for second printf) but it should print a string.

View 3 Replies View Related

C++ :: Use The Void Pointers?

Nov 25, 2013

how can i use the void pointers? i understand that can recive an adress variable(&). but can recive a value?

Code:
int a=5;
void *d;
b=&a;
b=100;//???

why i can't do these?

View 14 Replies View Related

Visual C++ :: Value Of Pointers

Feb 5, 2013

I'm trying to figure out the value of pointers after the following code snippet

Code:
int s[8] ;
int *iptr1, *iptr2 ;
int **iptr3 ;
for (int i = 0 ; i < 8 ; i++)
s[i] = 7 - i ;

[Code] ....

I need to find what the value of iptr1, iptr2, and iptr3 are after the code is executed.

View 3 Replies View Related







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