C And C++ - Function - Extend It So That It Also Returns A Usable Array Of Pointers To Some Structures

Feb 18, 2009

Correct the problems with this function, and then extend it so that it also returns a usable array of pointers to some structures.

The extended version of this function should: Maintain the same "char *" return type which returns a pointer to a usable, for storing a C string, memory buffer.

In addition, also return a usable array of pointers to structures. This array of pointers is of variable and random length, which must be obtained using GetNumberOfSomeSeqsToGenerate(), which is called, ONLY, from within this new extended version of the function.

The type of these structures and the function that should be used to get these structures are defined as follows:

typedef struct {
char* name; /* '\0'-terminated C string */
int number;
} SomeSeq;

[CODE]...

View 2 Replies


ADVERTISEMENT

VS 2005 Unmanaged API Using Structures/pointers And ***?

Aug 23, 2011

I am in the process of writing a tool to manage DHCP servers using the DHCP Server API. Its an unmanaged DLL so using it is a PITA at least for me it has been.Currently I am stuck trying to enumerate the IP ranges in a particular IP subnet. I am able to access an array of structures but I have only been able to access the first structure in the array of strucutres.Using this I can sucessfully access the first structure in the array.

Dim element_info_array As DHCP_SUBNET_ELEMENT_INFO_ARRAY
Dim element_data_ptr As LPDHCP_SUBNET_ELEMENT_DATA
...
element_data_ptr = DirectCast(element_info_array.Elements, LPDHCP_SUBNET_ELEMENT_DATA)

However when I use this to try and loop through them one at a time it does not work. The ptr returns 0 is null.

Dim element_info_array As DHCP_SUBNET_ELEMENT_INFO_ARRAY
Dim element_data_ptr As LPDHCP_SUBNET_ELEMENT_DATA
For i = 0 To size

[code]....

The sizeof for DHCP_SUBNET_ELEMENT_DATA could be off due incorrectly setting up the union structure for it. I was not sure how it define it so that only the first ElementType and one of the other components is avalible at any given time. It wont even read the first pointer though so that has not even come into play yet.

<StructLayout(LayoutKind.Sequential)> _
Public Structure DHCP_SUBNET_ELEMENT_DATA
Public ElementType As DHCP_SUBNET_ELEMENT_TYPE

[code]....

View 3 Replies

VS 2008 : Function Returns A 2D Array?

Mar 18, 2011

i am trying to write a function which should return a 2D array , please advise what is wrong with.

vb.net
Public Function Cursor(ByVal SQL As String, Optional ByVal PARA1 As String = "", _
Optional ByVal PARA2 As String = "") As String(,)
Dim Cols, roWES, I, J As Integer

[code]....

View 3 Replies

Write A Function That Returns The Number Of Duplicates That Exist In An Array

May 18, 2009

Write a function that returns the number of duplicates that exist in an array.

View 2 Replies

Extend The Function Class?

Oct 31, 2009

is there any way to extend upon a procedure itself?like i want to be able to do the following

Code:
public sub test()
msgbox(special())

end sub and it should popup a string, let's say "cool", plus i shld be able to use special() in every single sub but if we call special() from a function it should be rejected. how can that be done?

also, we should also be able to do the following

Code:
public sub test()
msgbox(specialvariable)

end sub whereby specialvariable is accessible by every sub.

View 3 Replies

VS 2008 Aking DLL's For Software To Extend Its Function List?

Nov 5, 2009

Has anyone ever used Game Maker 7?

I was wondering, if anyone had any information on making DLL's for this software to extend its function list.

View 2 Replies

Array.Sort Returns Blank Data When Sorting A Structure Array?

Jun 19, 2009

I'm trying to sort an array based on a structure but whenever I do this, it basically erases all the data in the entire array.I have verified that the array is populated correctly, it is when using array.sort that everything returns blank.

View 6 Replies

Initialising An Array Of Structures

Nov 7, 2009

I have a Structure, and I am having trouble initialising it. Specifically when I try to populate the Vector3 variables, it tells me that they are Nothing, so I need to make them New when the array of this structure is declared.[code]Structures cannot declare a non-shared 'Sub New' with no parameters.I have no parameter to supply, and this will be an array so I'm not even sure how I would supply it.The second option to fix the error is to make the Sub New shared, but then I get other errors: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.Does anyone know how I can resolve this. My end goal is to have an array of this structure type with the Vector3s ready to use.

View 6 Replies

Need To Have An Array Of UDTs(Structures)

Feb 21, 2012

I need to have an Array of UDTs(Structures). Elements have to be added (at end) and removed (from anywhere). The different values of the elements need to be changeable.

I know how to implement it as an oldstyle array, but wouldn't it be better to implement as a List ( of T)? and if yes is such a procedure possible?[code...]

View 8 Replies

Save An Array Of Structures In .NET?

May 31, 2011

I have 2 Structures

Public Structure One
Public ItemOne As String
Public ItemTwo As Integer
End Structure

[Code]...

Results In an Unhandled exception. Bad Record Length. and then If I close it and reopen it I get an 'Unable to read beyond end of stream' error. So what is the best way to save an array of structures? Binary Reader/Writer? and why does this way not work (Even if its derived from VB6)

View 2 Replies

Sort An Array Of Structures In .NET?

Nov 17, 2009

I have an array of structures:
Structure stCar
Dim Name As String

[code].....

View 4 Replies

Using Fixed Array Within A Structures?

Apr 19, 2010

I have a class file which contains a structure like this.

<StructLayout(LayoutKind.Explicit)> _
Public Structure SampleStructure
<FieldOffset(0)> Public field1 As Int16

[Code]......

View 2 Replies

Populating From Datagrid To An Array Of Structures

Mar 23, 2009

how to go about getting data populated from a data grid view to an array of structures? I have a data grid view with 6 fields and 10 records that match elements in my array. I declared a list of songs based off of my structure Song.

[Code]....

View 6 Replies

ArrayList Versus Structures - 'array Of Records'

Jun 23, 2009

Is an ArrayList the same thing as a Structure (i.e. 'array of records')? If they're not the same think, what't the difference?

View 3 Replies

Error When Assigning Elements To An Array Of Structures?

Mar 21, 2011

I am getting an error when helping someone with their code. They are trying to create an array of Items, but gets an error at ItemStruc(counter).ItemName = Contents(0)

I am not sure why. >_>

Structure is as follows:
public structure Item
dim itemName as String

[Code].....

View 2 Replies

Read Text File Into Array Of Structures?

May 9, 2012

�On load read data from units.txt into an array of structures;�Allow the user to choose a major and then add units to a study plan.Note your program must not allow the user to add units not in the major and a unit can only be added once to a study plan;�Save student first name & last name, student number, unit codes to a user selected file (e.g. fred.txt); �Allow the user to select a student file to load using a common dialog control ;�Display the units for that student.

The program must have the following features:�It must use a common dialog control for saving data;�The program must have at least one general procedure; �The program must demonstrate the use of an array (array of structures recommended).I've attached a copy of the text file needed to be loaded.

View 5 Replies

VS 2008 Bubble Sort Array Structures?

Apr 15, 2009

I've learned about and understand HOW to do a bubble sort (theoretically), but I can't seem to wrap my head around how to use a bubble sort with array structures. I'm supposed to be able to sort the inputted student information (via textfile) using bubble sort and display the result in a listbox. Buttons for Sort by last name, sort by gpa, & sort by letter grade.

[Code]...

View 8 Replies

Can't Get Data From Text File To Load Into An Array Of Structures

Dec 22, 2009

I am trying to get the data from the text file to load into an array of structures and then be displayed in a listbox on FormLoad with no luck, all I get is a blank listbox.

Code:
Public Class frmMemList
'Create a structure to which data from text file MEMBERPHONES.TXT will be read.
Structure MemberList

[code]....

View 6 Replies

Can't Get Data From Text File To Load Into Array Of Structures?

Dec 22, 2009

I am really struggling lately for some reason. I do not know why, but I can not get simple programming code to work, usually due to simple mistakes. Anyway, enough about that.Here is my code, I am trying to get the data from the text file to load into an array of structures and then be displayed in a listbox on F

Public Class frmMemList
'Create a structure to which data from text file MEMBERPHONES.TXT will be read.
Structure MemberList

[code].....

View 7 Replies

Create And Initialize An Array Of Structures Of A Fixed Size?

Mar 6, 2012

I am trying to create and initialize an array of structures of a fixed size. Each struct will be populated when a button is clicked. Here is an example of my struct:

public structure buttonStruct
dim x() as Boolean
dim y() as Boolean

[code]....

In my form_load function I am declaring the array of structs and:

Dim BtnStruct(15) As ButtonStruct
BtnStruct(0).Initialize()

[code]....

Whenever a specific button is clicked, I am trying to collect data and store it in the respective struct and so for example, if button 1 is clicked then I will store the data associated with button 1 into BtnStruct(0). The position of the button is stored in a public variable called BtnNum. If I attempt to store information in the struct inside another function as follows, I receive an error

BtnStruct(BtnNum).x(pos - 1) = temp "btnstruct is not declared. it may not be inaccessible due to its protection level"

View 6 Replies

Read Binary Data In An Array Of Objects Or Structures?

Dec 27, 2011

I need to create a collection of millions of objects, each object has 3 double and one integer fields.If I remember (after more than 20 years without using C) in C you would allocate enough memory using a struct and an array, and read all the file content in one shot.In VB I created a class with the 4 members, and this constructor:

Sub New(BR As IO.BinaryReader)
X = BR.ReadDouble
Y = BR.ReadDouble

[code]....

View 11 Replies

Writing And Reading Simple Structures From Files Into An Array

Dec 23, 2010

I coded anything but I remember when using VB6 or Pascal/Delphi we used to define records/ structures with fixed length fields, then write those structures to a file knowing that they would always be the same length. You could then open a particular record within the file or simply find out how many records existed by reading the file length.From what I understand, it seems that such methods are depreciated in VB.NET and such structures are written as a stream.Does it now mean that we can define things like variable length strings and not need to worry about buffers or boundaries?Is it possible to read through such files and pick out individual records? Are there methods of determining how many records that exist in a file? What I'm looking to do is simply store multiple records of a structure in a file then retrieve them into an array so I can manipulate their order by sorting the array and search within the array. This is only a learning project so it is unlikely that the resultant array is going to be large, although if this is not generaly a good method of doing this then it might be interesting to fidn out what is. So far, I have read that they way to write a structure to a file is to "serialises" it and then write the bytes - is this correct?[code]

View 5 Replies

Array Of Structures Method - Get The File Read And Printed Onto A List Box?

Apr 17, 2012

These are the directions for the assignment.So far I am able to get the file read and printed onto a list box.The book we have for the class does not clearly talk about using the array of structure method with formatting an imported text file.After that I'm pretty much having a bit of trouble with everything else.I know I can figure most of it out but what I'm having a big amount of trouble with is the array of structures that he wants.I know that when I have the file imported that I need to save it temporarily and go through it and at every ":" put it in an array and save that spot and then keep scanning through the file. I know it is going to be a for loop using the index to count through but I'm not sure if how to start it.This is how the text file that he wants sorted out looks.

Ally Gators:Tim Tebow:240:280:250
Ally Gators:Albert Gator:150:175:222
Ally Gators:Joe Cool:195:220:217[code]...........

View 20 Replies

.NET Function That Returns PDF?

May 9, 2011

I'm trying to create a function that would return a PDF document. Something like this:

Function GetPDF(ByVal DirectoryPath as String) as PDF
Return DirectoryPath
End Function

View 1 Replies

Function Always Returns A Value Of 0?

Mar 25, 2011

I have to cut down the amount of code in my blackjack program so im trying to use a function however the function always returns a value of 0 I have tried putting in "return cardvalue" but it still comes out as 0 I dont know where I went wrong or if the code im using can even be used as a function.

Function Values(ByVal deal() As Integer, ByVal counter As Integer, ByVal cardvalue As Integer) As Integer
If deal(counter) = 1 Or deal(counter) = 2 Or deal(counter) = 3 Or deal(counter) = 4 Then

[Code]....

View 4 Replies

Call A Function That Returns A Value?

Apr 28, 2012

I wrote a vb program that would prompt the user to enter a number and then enter the exponent value they wanted the number raised to. When they clicked button 3 it did the calculation. everything worked perfectly.

Now I need to change the program. I must create a function in a module and then call that function from button3 click event. I have tried several different ways and even though it seems to "work", it keeps returning an incorrect value![code]...

View 6 Replies

Function That Returns A 'Table'

Mar 9, 2009

I have to create dinamcly a Table ( not a DataTable) and I need to write the Functions in other class... so I need to create a function that Returns a Table to make possible I just atribuite the Table to my <asp:Table> control.

[Code]...

View 3 Replies

.net - Function That Always Returns The Next Integer In A Sequence

Feb 10, 2012

I need top create a function that gets the next integer in the sequence of 1 to 60. Each time the function is called, I need it to increment from what the last value was and return the next number as the result. It also cannot return the same integer in 2 consecutive calls. When the count gets to 60, the sequence needs to reset back to 1. I would like to function to have no parameters.

I have created a function that does this using the cache to store the last value that was returned, but I am worried that with concurrent calls to the function that it might not work as I expect and 2 calls could get the same integer.

Is cache blocking the correct method to use in this instance or is there something other method I am not thinking about?

Also, stuck using .Net 3.5 and this is a web application.

I just wrote this function based on using SyncLock. Any obvious problems with it that I don't see? I am using the Cache to save the last value that was returned.

Private Shared Function GetNextNumber() As Integer
Dim o As Integer
Dim r As Integer

[Code].....

View 4 Replies

C# - Should A Function That Periodically Returns Bitmaps Re-use Them?

Jul 21, 2010

I have a function that returns a bitmap meant to be used as background in a panel, and occasionally I'd have to call it to create a new background based on parameters

View 2 Replies

Call A Single Function With Different Returns

May 5, 2012

How can I call individual parts of this function? I would like to call return Gallons and decPaintCostperRoom as individual entities with a single function.

[Code]...

View 5 Replies







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