dynamic

Dynamic array in C cause segmentation fault

别来无恙 提交于 2019-12-13 04:03:51
问题 I have defined a dynamic array this way: double *n_data ; int n_data_c = 0, n_cnt = 0; n_data_c = count_lines_of_file("abnorm"); n_data = (double *)malloc(n_data_c * sizeof(double)); in a loop I calculate distance and do so: n_cnt++; n_data[n_cnt] = distance; but it returns segmentation fault here : n_data[n_cnt] = distance; I want to know if I'm doing something wrong. 回答1: Check what malloc returned, if it returned 0, then it failed. More likely, I think, is your n_cnt is out of bounds. If

How to generate a table with dynamic amount of colums (and a fixed set of rows)?

对着背影说爱祢 提交于 2019-12-13 04:00:01
问题 I have some calculations in the area of payroll which result in a lot of data each per month/year and two dates: an begin date (mm/yyyy) and an end date (mm/yyyy). What I want: generating an internal table which has as many columns as begda-year till endda-year has (in years). For example my begda is 05/2010 and endda is 03/2013, then I need a table like this which has columns 2010, 2011, 2012, 2013 and rows for each month: The difficult part for me is, that the table colums (or the endda and

Using recursion and dynamic memory allocation of multidimensional arrays to find the determinant of an NxN matrix

浪尽此生 提交于 2019-12-13 03:59:51
问题 I'm trying to write a program that can calculate the determinant of any NxN matrix regardless of the size but there's something wrong with the program and it crashes for any matrix with size greater than 1. I'd be very grateful to anyone who can tell me what I'm doing wrong. I'm new to c++ and dynamic memory so, take it easy on me please (:. Here's my program: #include <iostream> using namespace std; int determinant(int *matrix[], int size); void ijMinor(int *matrix[], int *minorMatrix[], int

2d dynamic array (in C) with specific row number and different column size in each row

纵饮孤独 提交于 2019-12-13 03:59:20
问题 How do I make a 2d dynamic array (in C) with specific row number and different column size in each row? For example: This is an array (3=rows) |1 | 4 | 5 | |3 | |6 | 2 | 1st row - 3 columns 2nd row - 1 column 3rd row - 2 columns I want my program while running to ask the user for every row to give the number of cols. How do I make an array like this? 回答1: If you want something dynamic and don't care about constant access time, you can create an array of linked list, otherwise you have no

Change column font style runtime in crystal report

烂漫一生 提交于 2019-12-13 03:59:16
问题 I have Crystal reports in my project that is designed using a data set (Having table with column name inLanguage1, inLanguage2). This data set is filled with data from one of the tables from a database, each table have two columns that store names in two different languages. Eg: Table 1 has name in Hindi and English. Table 2 has name in English and Hindi. Table 3 has name in Kannada and Hindi. While I store names in these tables, using my frontend (C#), I have set the corresponding font type

Adding Dynamic Data Series to High charts

旧巷老猫 提交于 2019-12-13 03:55:01
问题 ×212414 ×123754 I am calling a PageMethod in codebehind.aspx.cs file which returns me a string array[] in the javascript code in the aspx page the problem at hand is that string array returns Time(X axis-Value),Data/Name(Y axis Value),Type(Defines the type of chart (Spline or Column)) from a WEB SERVICE. I am using that data to add series dynamically to the chart. Using the function chart.AddSeries() but I am unable to do so. Can anyone please guide me how to do that and upon doing that I

PHP Moving config mapping file to XML but how to I create a dynamic XPATH

拥有回忆 提交于 2019-12-13 03:54:13
问题 So I have a PHP file that I use to define all my constants but now want the flexibility of using a XML instead. Example PHP Config file define("LOGIN_URL", "secure_login.php"); define("REDIRECT", "redirect.php"); define("MAPPED_VALUE_GREEN", "object_green"); define("MAPPED_VALUE_KEY", "object_key_12345"); What I'm going to do is: <scriptNameConfig> <urls> <url alias="LOGIN_URL" scriptname="secure_login.php" location="optional/path/to/file"/> <url alias="REDIRECTL" scriptname="redirect.php"

Displaying data from database not working properly in PHP/javascript

☆樱花仙子☆ 提交于 2019-12-13 03:49:59
问题 I have a survey form displaying questions, answertype and number of options from my question table. Here's my code. <?php session_start(); ob_start(); $con = mysqli_connect("localhost","root","","imetrics"); $id = $_REQUEST['survey_id']; $query = "SELECT SF.survey_id, SF.surveytitle, SF.survey_description, SF.surveycategory, C.categoryname AS pcatname, SF.surveysubcategory, SC.categoryname AS scatname, SF.gender, SF.age_start, SF.age_end, SF.occupation, SF.date_created, O.name, SF.location,

Dynamic content in xaml

馋奶兔 提交于 2019-12-13 03:45:31
问题 If I want to display something based on condition, then the simple approach is to use visibility binding: <Something Visibility="{Binding ShowSomething, Converter=..." ... /> With this approach the visual tree is still created and can cause performance issues if Something has complicated structure (many children, bindings, events, triggers, etc.). A better approach is to add content via trigger: <ContentControl> <ContentControl.Style> <Style TargetType="ContentControl"> <Style.Triggers>

How add function name to handler click? [closed]

て烟熏妆下的殇ゞ 提交于 2019-12-13 03:43:37
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I have a button and I have function which should execute on click. example: <button id="button1">bla bla</button> <script> var justFunctionName = "function1"; var function1 = function() { alert("!"); } $("#button1").click(justFunctionName); </script> 回答1: HTML <button id="button1">bla bla</button>