C++ :: Two Dimensional Array In Form Application - Memory Corrupt
Mar 9, 2013
I'm using C++ Form Application in Visual Studio 2010. I defined a new two dimentional array. like this "static int dizi[26][26];" I want to change the value when I clicked the button1. For example, I can change as dizi[2][3]=1. But I couldn't change like in this code. dizi[a][b]=1 didn't happen.
Error is... "access violation exception was unhandled. attempted to read or write protected memory. this is often an indication that other memory is corrupt."
I don't use zeroth variable here.So, It started from 1. My problem is variable can't be changed.I can't assign a value to variable. I have to use 'ogrenci[i].ders[j]'s index for dizi array in this code. It's really weird.
the question is; Write a program that prints out the memory addresses of each element in a two-dimensional array. Check to see if the values printed out make sense to you based on the way I explained it before.
Below is the code I have done. I am having problems printing the "-" sign to keep formatting with the board when the user enter in different dimensions other than [4][4].
Code:
#include <iostream> using namespace std; void printTable (int x, int y) { int **p_p_twoDimension = new int* [y]; for (int i = 0; i < y; i++) { p_p_twoDimension[i] = new int [x];}
As a starter project I want convert a Neural net app from "AI Techniques for Game Programming (2002 Buckland)" to a Visual C++ CLI Forms application. I have created the interface and now I have to rewrite the in/output routines, amongst other things.
First question I have has to do with variable initialization used by Buckland. Code looks like this:
Excerpt from header file (CNeuralNet.h):
//------------------------------------------------------------------- //define neuron struct //------------------------------------------------------------------- struct SNeuron { //the number of inputs into the neuron int m_NumInputs; //the weights for each input vector<double>m_vecWeight;
[code]....
Question I have: what is the the function of ": m_NumInputs(NumInputs+1)" after the method declaration? Buckland does this in many places in his code. In this case it's a struct, but he does it with classes too.
I'm building a Windows Form Application using MVP Design Pattern; the application is quite simple, it just calculates the sum of two number; So I have a form in which are located tree textbox: number1 number2 and result, plus a button to perform the action.
using System; using System.Collections.Generic; using System.Linq; using System.Security; using System.Security.Principal; using System.Text; using System.Threading; namespace WindowsPrincipalTrial { public class Program
I want to write my own application which would fetch some data from a web site. I need to parse the HTML code of the web site and get the data.
About the application:A form (main form) that will contain data arranged in rows. Some of the data comes from a web site and some of it comes from a database.The data that comes from the web site needs to be updated every few seconds so I need to keep fetching the data from the web site.The main form will contain a button "add" which when clicked will add a new row. New data can be added to this row by the user.
I am not sure what to use for this. I have been writing the application as a Windows Form Application (Visual C#) but I do not know whether this is the best choice. Should it be a windows form application or web application? Should I use something else?
I wrote this code behind a button " colordialog.showdialog(); File.WriteAllText("dlg.txt",this.BackColor.Name); " And I wrote this code in Form Load as well " this.BackColor = Color.FromName(File.ReadAllText("dlg.txt")); " but I got an error and I dont know what is this.... "Control does not support transparent background colors"
How can I concatenate two 2-dimensional int arrays into one larger 3-dimensional array. This question is also valid for the 3-dimensional vectors. I know the command for the one dimensional vector as:
This is the question; Write a function that builds a two-dimensional multiplication table with arbitrary sizes for the two dimensions.
This is what I have done. I have allowed the user to input whatever size table they want by arbitrarily choosing what value they can input. However I cannot get the board to have blank squares. I thought the char would do it.
Code: #include <iostream> using namespace std; char SQAURE_CHAR = {' '}; const int Board_Size = 14;
I have a question about allocating 2MB memory then filling it...
@ Platform: => DOS, and application is compiled/linked via Watcom C + DOS32/A (...memory model is "flat" mode)
@ phenomenon: 1. I allocate 2M memory by calloc() function. Then I got "!NULL" and it means allocating 2MB memory is ok( right ? ) 2. then I tried to "fill" this 2MB memory by for loop(one byte by one byte) like below:
for( DWORD i=0; i<0x200000; i++) { *((BYTE *)(A[0].B[0]->C) + i ) = 0x5A; // C is 4-byte address value }
here : * DWORD means "unsigned long(4-byte)" and 0x200000 means "2MByte" * in actual case the value of pointer(to allocated memory) is 3019AF3C(~768MB) <- running in flat mode...
3. after filling this range of memory(2MB) the application crashed...
@ my observations: 1. if allocating 2MB and no fill(no write data to memory) => OK 2. if allocating 2MB and just fill the former 32 bytes => OK 3. if allocating 4KB and fill all => OK
my question is: why can't I filling this 2M memory totally "even memory allocation succeeds" ?
I had a hard question in my C++ final exam and I'm trying to solve it for the last 3 days. I haven't succeded yet! Here is the question: You have a one-dimensional array A[20]={1,2,3,4,...,20} and B[5][4] you have to assign the A array's elements to the B array but there is an order which is: B[5][4] = { { 12, 9, 11, 10 }, { 14, 7, 13, 8 }, { 16, 5, 15, 6 }, { 18, 3, 17, 4 }, { 20, 1, 19, 2 } } and there is a restriction: you can only use ONE for statement, nothing else!
#include <iostream> #include <iomanip> using namespace std; int main(){ int A[20] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; // define A array's elements. int B[5][4] = { 0 }, k = 1; // define B array and k counter.
[code]....
I can't narrow the statements to one,This program works perfectly but it shouldn't be that long, we need ONLY ONE FOR statement, not two!
I am writing a console application that creates a shuffled deck of cards using pointers and arrays, but I get the error "Run-Time Check Failure #2 - Stack around the variable 'deck' was corrupted" What's the stack? What does this mean and what did I do to cause the stack to be corrupt?
I have a question concerning shared memory (in linux-environment). In our company we currently have an application that is restarted once in a while. There are multiple instances running of this application (on different physical machines), and all access the same centralized database. Because of IO and Network bottleneck the start gets very slow, and takes about 10 Minutes. Besides some new data, most of the data stays the same, so reading from the database again is quite redundant. An idea is to write all relevant object to a shared memory segment, when the application is shut down. A second dummy process attaches to the same shared memory (just so that some process is still attached). If the application is restarted, it is attached again to its shared memory, and reads it to its own adress range again. There might occur a difference regarding the data so it might me necessary to load some new data afterwards, but that is different problem.
The current idea is to serialize all Objects (could be about 1-2 Gigabyte) with Apache Thrift, and write them into shared memory. With Thrift the data is more or less ordered, so creating the objects anew is possibly easier (not sure here).
My Question is:
- Does it even make sense to consider shared memory in this scenario. I've read a lot stuff about in the last few days, and for now I don't see big disadvantages (except if the application crashes, in this case I've to read from database again). On the other hand I don't know how to really implement this functionality (as I'm no experienced Developer)
- Should I aim for Boost::Interproces, considering even memory mappable files, or stay with the traditional shmat (and stuff..)?
- I guess 1-2 Gigabyte shared memory will be necessary. This amount is only needed in the gap between application shutdown and restart. Will the sheer amount of needed shared memory be a problem (all examples I found just used a few Bytes or Kilobytes)
The application that I ported from 32 bit linux to 64 bit linux is crashing due to unknown memory corruption Also some time teh address is printed in 32 bit only as below
I have a 3D array that contains 200 strings. I'm trying to copy all these strings into a 2D array. How can this be done? This is what I have so far but it isn't working correctly.
Code: for(int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { dest[i][j] = source[0][i][j]; } }
The finished product would be with 100 rows, 2 columns.
Write a program using user-defined function which accepts an integer array and its size as arguments and assign the elements into a two dimensional array of integers in the following format: If the array is 1,2,3,4,5,6, the resultant 2D array is
I have a non form class. I want to update label/ check status of check box etc.. in non form class ( here resides functions that contains logic). How can i do that ?
This is more of a Application Design question, Let's say I have Form1(Login), this is opened from Program.cs, when the user enters details, the Event Handler makes a instance of a class, adds the data and stores the instance within Program.cs class.
So the best thing to do here, is to close the Form1(Login) and open Form2(Main) via Program.cs so that I can send the List<Login> object with my Login instance objects to said form. This form will remain open throughout the applications use as it's like the main GUI for all the programs functions.
When I close this form, I may want to save some information before the application is terminated, so I may as well store the Login instances in Program.cs anyway.
Main stepping stone: Multiple (usually around 3 max) users can login this system if need be, which will mean closing Form2(Main) and then opening Form1(Login) so that once Form1 is closed it can recreate the From2(Main) form and pass the new List<Login> to that form.
What's the best way to do this, at the moment i'm creating the Form2 instance like so:
//.... //Detect the Login form being closed loginForm.Closed += new EventHandler(OnLoginClosed); //... //Open the main form when the login is closed private void OnLoginClosed(object sender, EventArgs e)
[Code] .....
This seems like it will work and do the job, but is there a better and cleaner way? The List<Login> will be passed to Forms which are created via Form2(Main) as this information will be needed. It's just that ive been told not to use Forms for too much data containment.