473,594 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic 2d array

6 New Member
Hi everyone,

I am new at programming. I was googling for how to create an 2d dynamic array. But I couldnt find what i want.

I want to create an array which i will define during run time. For example i will say i want to input an array which is 2X3. But normally it should work for any size. And then i will input 6 numbers which are all unsorted. After compiling and running the program the numbers will be outputed in sorted and ascending order.

Can I also search the array for a number? For example I will input 5 and it will tell me if it contains 5 and at which location in array.

thanks for you help from now
Oct 18 '06 #1
1 2711
Banfa
9,065 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. int *data = malloc(sizeof(*data)*2*3);
  2.  
  3. int **pseudoarray = malloc(sizeof(*pseudoarray) * 2);
  4.  
  5. pseudoarray[0] = data;
  6. pseudoarray[1] = pseudoarray[0] + 3
  7.  
;
Oct 18 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2822
by: Vasileios Zografos | last post by:
Hello, I have a function that generates some values (e.g. vertices in 2d space) the number of which I dont know. So, it could generate 20 vertices, 100 vertices, or even 1 vertex. void generateVals() { ..... //generate some values
4
7670
by: Scott Lyons | last post by:
Hey all, Can someone help me figure out how to pass a dynamic array into a function? Its been giving me some trouble, and my textbook of course doesnt cover the issue. Its probably something simple, but its just not popping into my mind at the moment. My little snippet of code is below. Basically, the studentID array is dynamic so it will fit any length of a Student's Name. What I'm trying to do is place this chunk of code into a...
5
3400
by: meyousikmann | last post by:
I am having a little trouble with dynamic memory allocation. I am trying to read a text file and put the contents into a dynamic array. I know I can use vectors to make this easier, but it has to be done using dynamic arrays. I don't know the size of the text file ahead of time, though, so I created a class that includes a method to resize the array. Here is that class: class Data { public: Data(int initialsize);
8
3671
by: Peter B. Steiger | last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C is a simple word game that involves stringing together random lists of words. In the Pascal version the whole array was static; if the input file contained more than entries, tough. This time I want to do it right - use a dynamic array that increases in size with each word read from the file. A few test programs that make use of **List and realloc( List, blah...
6
2970
by: Materialised | last post by:
Hi Everyone, I apologise if this is covered in the FAQ, I did look, but nothing actually stood out to me as being relative to my subject. I want to create a 2 dimensional array, a 'array of strings'. I already know that no individual string will be longer than 50 characters. I just don't know before run time how many elements of the array will be needed. I have heard it is possible to dynamically allocate memory for a 2
1
4451
by: lemonade | last post by:
Hello! Can someone explain to me the difference between dynamic array of pointers vs dynamic array of objects by giving a real life example. Following is the code that I am using for dynamic array of objects. I am skipping initialization and other member functions. class Inventory { Item *itemList; int idx, count, size;
2
7039
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
0
2698
by: pjr | last post by:
Using VS2005, I dynamically create an event delegate. Code follows question. My method gets the event's parameters and passes them onto a common event handler. My delegate gets called when expected and in turn, calls my common event handler. However, once in the common event handler code, the "this pointer" is wrong and hence I can't access other class properties and methods. Even if I invoke the dynamic method directly, the "this pointer" is...
11
7685
by: C C++ C++ | last post by:
Hi all, got this interview question please respond. How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Rgrds MA
13
8935
by: kwikius | last post by:
Does anyone know what a C99 dynamic array is, and if it will be useable in C++? regards Andy Little
0
7936
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3853
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1469
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.