Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

arrays

  1. X

    I don't understand multi dimensional arrays using pointers and pointers in arrays

    I tried to understand these two codes : int *pv = (int*) malloc(5 * sizeof(int)); for(int i=0; i<5; i++) { pv[i] = i+1; } This is a one dimensional array. And I am confused of how malloc works and why it is also a pointer (int *) ?? Because I had more simple examples such as...
  2. cicikamarena

    How do I maintain relations in struct while merge sorting int array?

    Does anyone know how I could maintain relations between the char and int in structs while merge sorting the ints in the struct? So if I had nameandnumber[1].buffer assigned a value that used to be at nameandnumber[7].buffer, nameandnumber[7].phrase would get moved to nameandnumber[1].phrase? My...
  3. jaredcb

    JavaScript Getting the sum of equal array elements, and creating a new array

    I'm scratching my head over this one. Not sure if I'm asking this question wrong, but I'm trying to reach out where I can hopefully find someone who knows what I can try. I tried asking this on another forum, and they didn't like that I didn't have any example of failed code yet, so they...
  4. T

    JavaScript Creating a new array from recursive mapping

    I am attempting to do something very complex. I have a database that has a self relation (categories that contain a nested category). The ORM I’m using makes use of these categories as objects: category = [ { name: "Lights", description: "some description", parentid: "some id"...
  5. E

    JavaScript Can someone explain why I'm getting zeros in my missed_questions array?

    Here's the javascript code I did, public class SamDriverExam { private char []exam_answer_key = {'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'}; private char []student_answer; public SamDriverExam(char []exam_answers) {...
  6. P

    JavaScript How do I loop through an array and display each item in the HTML page on a new line?

    Hi, I am new to JS from Python. I am trying to create a To Do List in JS, and I am trying to loop over an array that contains the added items. I want each item in the array to appear on a new line in the web app. The best I can get is for the items to be displayed like this item1,item2,item3 I...
  7. S

    JavaScript querySelector works, but not querSelectorAll

    I want to replace all .emoji elements, with a random weather emoji. I have written the following code to randomize an emoji: let weatherEmojis = [ "⚡️","☀️","⛅️","☁️","💧","💦","☔️","💨","❄️" ]; var weatherEmoji = weatherEmojis[Math.floor(Math.random() * weatherEmojis.length)]; And the...
  8. N

    JavaScript get max sum of multiple functions

    I'm trying to get the largest number of this 3 functions then store in an array, the variables of that function and their amount..can be done? //this must be the result var result = [50,55,60,165] // function r2 function r1(){ var x = 5; var a = 10; var b = 10; return x+a+b // 25 } function...
  9. Sidddharth

    JavaScript Script to find the number from table and store the index into variable.

    Hello Everyone, I want to take input from user and on basis of the input i want to show the correct value of it. For example if user enters number 5. The correct value from the below table i.e. 1 should be displayed. Table 1 Input Value 0-5 1 6-10 2 11-15 3 16-20...
  10. datastructures

    Visualizing arrays with a basic computing problem

    I have something that has been bugging me for a while now. From the wikipedia entry on arrays This is the wikipedia page https://en.wikipedia.org/wiki/Array_data_structure. Take a simple mysql table with the following fields The table has products in it and i want to query this table and...
  11. M

    Increment of arrays

    I am struggling with the difference in array incrementation. For example if I had an array. char* arr = ["a", "b", "c", "d", "e", "f"] and if given arr[0] then the element that it is reffering to is "a", and arr[i +2] is "c". But if the incrementation was arr[i]+2, then what is the element is it...
  12. TechnicalTobi

    C Why is fread and fwrite giving error 'containing too many arguments'?

    I am working on a project in which data from .bin file have to be transferred to .csv . The data consists of many points each containing 4 values in varying dataformats, them being Time stamp, Pressure, System state and Alarm state. Unfortunately the same error, being 'too many arguments to...
Back
Top Bottom