[Solved] character and array [closed]

char name; This gives you a single char object. char name[5]; This gives you 5 char objects, one after the other – this is called an array of 5 chars. You can index them with name[0], name[1]… until name[4]. “best” This is a string literal. It represents an array of 5 chars in read-only memory, … Read more

[Solved] Writing ( and ) in a regex doesn’t work

What about this regex? \(‘(.*)’\) You need to escape ( and ) since those are reserved in Regex. So every time you encounter a ( or a ) which you want to evaluate as a literal, you need to escape them. 8 solved Writing ( and ) in a regex doesn’t work

[Solved] Segmentaion fault in C

int *ptr; is a pointer to an interger, but you never initialized it. The value of ptris not defined so this is undefined behavior. To make your code work, the value of ptr has to be an address of a variable with type int. *ptr and **p_ptr tries to read the value where ptr refers … Read more

[Solved] Program Crashed (String Manipulation) [closed]

Perhaps like this. Note that string concatenation cannot be done on simple char types. #include <stdio.h> #include <string.h> int main (void) { char s1[] = “stack”; // skipped the string inputs char s2[] = “overflow”; char str[120]; size_t i; // var type returned by `strlen` size_t index = 0; size_t leng1 = strlen(s1); size_t leng2 … Read more

[Solved] Declaring variable within a function [closed]

int function(int a, int b){ // two variables, a and b, are declared and set equal to whatever you passed in when you called the function. a = a*b; // now you are using the two already-declared variables return(a); // return the value of ‘a’ which was declared in the first line and then modified … Read more

[Solved] Competitive programming: “Time exceeded error”

Calculate the cumulative sum of the array and store it in another one, that is to say, accumulated[i] = sum of numbers of the array up to ith index. This can be computed in O(n). Then for a query, the answer will be accumulated[r] – accumulated[l]. This is O(1) solved Competitive programming: “Time exceeded error”

[Solved] C++ How to distinguish Multimap with duplicate keys with value and and Unique keys with values in different map containers with O(n) traversal

C++ How to distinguish Multimap with duplicate keys with value and and Unique keys with values in different map containers with O(n) traversal solved C++ How to distinguish Multimap with duplicate keys with value and and Unique keys with values in different map containers with O(n) traversal

[Solved] Creating objects on click button event [closed]

i suggest keeping a collection of those objects for your form(or in another scope above the Button_Click method) and adding a new object to that in the event receiver like: var coll = new List<Classname>(); protected void Button1_Click(object sender, EventArgs e) { coll.Add(new Classname()); } 0 solved Creating objects on click button event [closed]

[Solved] Shortest path on 4×4 grid c++

As you have already pointed out yourself in the comments, the shortest path from (0,2) to (3,1) is “right 3 down 1” in other words: right 3-0=3 and down 2-1=1 And that’s already pretty much the answer… In general, how do find the shortest path from (xStart, yStart) to (xEnd, yEnd)? You just do the … Read more