Search Results

Search found 1523 results on 61 pages for 'assignment'.

Page 26/61 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Memory Leaks - C

    - by sbsp
    Hi guys, Is there a good application (that has some kind of gui) for testing memory leaks in c code. I would really like to test my assignment/programme but being very new to this, i struggle with using the terminal to do things, especially using gdb for debugging (to me it feels like a blast from the past, where i could be using some visual debugger). Thanks for the help

    Read the article

  • Big O Complexity of a method

    - by timeNomad
    I have this method: public static int what(String str, char start, char end) { int count=0; for(int i=0;i<str.length(); i++) { if(str.charAt(i) == start) { for(int j=i+1;j<str.length(); j++) { if(str.charAt(j) == end) count++; } } } return count; } What I need to find is: 1) What is it doing? Answer: counting the total number of end occurrences after EACH (or is it? Not specified in the assignment, point 3 depends on this) start. 2) What is its complexity? Answer: the first loops iterates over the string completely, so it's at least O(n), the second loop executes only if start char is found and even then partially (index at which start was found + 1). Although, big O is all about worst case no? So in the worst case, start is the 1st char & the inner iteration iterates over the string n-1 times, the -1 is a constant so it's n. But, the inner loop won't be executed every outer iteration pass, statistically, but since big O is about worst case, is it correct to say the complexity of it is O(n^2)? Ignoring any constants and the fact that in 99.99% of times the inner loop won't execute every outer loop pass. 3) Rewrite it so that complexity is lower. What I'm not sure of is whether start occurs at most once or more, if once at most, then method can be rewritten using one loop (having a flag indicating whether start has been encountered and from there on incrementing count at each end occurrence), yielding a complexity of O(n). In case though, that start can appear multiple times, which most likely it is, because assignment is of a Java course and I don't think they would make such ambiguity. Solving, in this case, is not possible using one loop... WAIT! Yes it is..! Just have a variable, say, inc to be incremented each time start is encountered & used to increment count each time end is encountered after the 1st start was found: inc = 0, count = 0 if (current char == start) inc++ if (inc > 0 && current char == end) count += inc This would also yield a complexity of O(n)? Because there is only 1 loop. Yes I realize I wrote a lot hehe, but what I also realized is that I understand a lot better by forming my thoughts into words...

    Read the article

  • C++ Why isn't call by reference needed for strcpy()

    - by Ribbs
    I have a homework assignment with a number of questions. One is asking why the strcpy() function doesn't need the call by reference operator for CStrings. I've looked through the book numerous times and I can't, for the life of me, find the answer. Can anyone help explain this to me? It is an array of sorts so I would think you would need the call by reference.

    Read the article

  • How do I assign functions in a dictionary?

    - by Ziv
    hi, I'm having a problem with a simple program I wrote, I want to perform a certain function according to the users input. I've already used a dictionary as a replacement for a switch to do assignment but when I try to assign functions to the dictionary it doesn't execute them... The code: def PrintValuesArea(): ## do this def PrintValuesLength(): ## do that def PrintValuesTime(): ## do third PrintTables={"a":PrintValuesArea,"l":PrintValuesLength,"t":PrintValuesTime} PrintTables.get(ans.lower()) ## ans is the user input what did I do wrong? It looks the same as all the examples I've seen....

    Read the article

  • Creating an instance within the Class itself

    - by didxga
    What's going on when the assignment statement executed at Line 4, does compiler ignore the new operator and keep the foo variable being null or something else happen to handle this awkward moment? public class Foo { // creating an instance before its constructor has been invoked, suppose the "initializing" // gets printed in constructor as a result of the next line, of course it will not print it private Foo foo = new Foo();//Line 4 public Foo() { System.out.println("initializing"); } }

    Read the article

  • Display alert msg in web page when forwarding from one page to another on page load.

    - by Shantanu Gupta
    I have created a html page in php and upon submission i validates that page using PHP. After validating i want to show an alert msg to show its status like showing any greeting or request for re-enter. I have dont validation. Now i m using header( 'Location: http://localhost/assignment/WebForm.htm' ) ; to redirect user to same page but with a alert msg at page load or something like that. What I need to do ?

    Read the article

  • Need a tool to detect memory leaks in C code

    - by sbsp
    Hi guys, Is there a good application (that has some kind of gui) for testing memory leaks in c code. I would really like to test my assignment/programme but being very new to this, i struggle with using the terminal to do things, especially using gdb for debugging (to me it feels like a blast from the past, where i could be using some visual debugger). Thanks for the help edit: platform doesn't matter - i am running everything ;)

    Read the article

  • makecontext segfault?

    - by cdietschrun
    I am working on a homework assignment that will be due in the next semester. It requires us to implement our own context switching/thread library using the ucontext API. The professor provides code that does it, but before a thread returns, he manually does some work and calls an ISR that finds another thread to use and swapcontexts to it or if none are left, exits. The point of the assignment is to use the uc_link field of the context so that when it hits a return it takes care of the work. I've created a function (type void/void args) that just does the work the functions did before (clean up and then calls ISR). The professor said he wanted this. So all that's left is to do a makecontext somewhere along the way on the context in the uc_link field so that it runs my thread, right? Well, when I do makecontext on seemingly any combination of ucontext_t's and function, I get a segfault and gdb provides no help.. I can skip the makecontext and my program exist 'normally' when it hits a return in the threads I created because (presumably) the uc_link field is not properly setup (which is what I'm trying to do). I also can't find anything on why makecontext would segfault. Can anyone help? stack2.ss_sp = (void *)(malloc(STACKSIZE)); if(stack2.ss_sp == NULL){ printf("thread failed to get stack space\n"); exit(8); } stack2.ss_size = STACKSIZE; stack2.ss_flags = 0; if(getcontext(&main_context) == -1){ perror("getcontext in t_init, rtn_env"); exit(5); } //main_context.uc_stack = t_state[i].mystk; main_context.uc_stack = stack2; main_context.uc_link = 0; makecontext(&main_context, (void (*)(void))thread_rtn, 0); I've also tried just thread_rtn, &thread_rtn and other things. thread_rtn is declared as void thread_rtn(void). later, in each thread. run_env is of type ucontext_t: ... t_state[i].run_env.uc_link = &main_context;

    Read the article

  • How do I declare a pipe in a header file? (In C)

    - by Kyle
    I have an assignment in which I need to declare a pipe in a header file. I really have no idea how to do this. It might be a really stupid question and I might be missing something obvious. If you could point me in the right direction I would greatly appreciate it. Thanks for your time.

    Read the article

  • Doubt in Conditional inclusion

    - by Philando Gullible
    This is actually extracted from my module (Pre-processor in C) The conditional expression could contain any C operator except for the assignment operators,increment, and decrement operators. I am not sure if I am getting this statement or not since I tried using this and it worked.Also for other manipulation a probable work around would be to simply declare macro or function inside the conditional expression,something like this to be precise. Also I don't understand what is the rationale behind this rule. Could somebody explain? Thanks

    Read the article

  • troubles creating a List of doubles from a list of objects

    - by Michel
    Hi, i have a list with objects. The object has a property 'Sales' which is a string. Now i want to create a list of doubles with the values of all objects' 'Sales' properties. I tried this: var tmp = from n in e.Result select new{ Convert.ToDouble ( n.Sales) }; but this gives me this error: Error 106 Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.

    Read the article

  • Strange ruby syntax

    - by AntonAL
    Hi, what the syntax is in Action Mailer Basics rails guide ? class UserMailer < ActionMailer::Base def welcome_email(user) recipients user.email from "My Awesome Site Notifications <[email protected]>" subject "Welcome to My Awesome Site" sent_on Time.now body {:user => user, :url => "http://example.com/login"} end end How should i understand the construction, like from "Some text for this field" Is it an assignment the value to a variable, called "from" ?

    Read the article

  • Constructors from extended class in Java

    - by Crystal
    I'm having some trouble with a hw assignment. In one assignment, we had to create a Person class. Mine was: public class Person { String firstName; String lastName; String telephone; String email; public Person() { firstName = ""; lastName = ""; telephone = ""; email = ""; } public Person(String firstName) { this.firstName = firstName; } public Person(String firstName, String lastName, String telephone, String email) { this.firstName = firstName; this.lastName = lastName; this.telephone = telephone; this.email = email; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public boolean equals(Object otherObject) { // a quick test to see if the objects are identical if (this == otherObject) { return true; } // must return false if the explicit parameter is null if (otherObject == null) { return false; } if (!(otherObject instanceof Person)) { return false; } Person other = (Person) otherObject; return firstName.equals(other.firstName) && lastName.equals(other.lastName) && telephone.equals(other.telephone) && email.equals(other.email); } public int hashCode() { return 7 * firstName.hashCode() + 11 * lastName.hashCode() + 13 * telephone.hashCode() + 15 * email.hashCode(); } public String toString() { return getClass().getName() + "[firstName = " + firstName + '\n' + "lastName = " + lastName + '\n' + "telephone = " + telephone + '\n' + "email = " + email + "]"; } } Now we have to extend that class and use that class in our constructor. The function protoype is: public CarLoan(Person client, double vehiclePrice, double downPayment, double salesTax, double interestRate, CAR_LOAN_TERMS length) I'm confused on how I use the Person constructor from the superclass. I cannot necessarily do super(client); in my constructor which is what the book did with some primitive types in their example. Not sure what the correct thing to do is... Any thoughts? Thanks!

    Read the article

  • replace new lines with comas in shell

    - by mpapis
    I want to replace new lines in text with coma or space but do not change the last new line. I know of this question: How to replace new lines with tab characters - but it does produce an tab on end instead of new line. So far I have come with: awk 'NR>1{printf","} {printf $1} END{printf"\n"}' Is there an easier way to do this? This is not an assignment, I am just curious want to level up my scripting.

    Read the article

  • How do I stop the designer from filling in my properties with null values?

    - by Tim Gradwell
    When I add a control to a form, visual studio assigns various of the properties of that form a value of null in the auto-generated designer code. I don't want the designer to make the redundant assignment (the value is already null). Can anyone tell me how to prevent it? example MyControl has property public SomeClass MyProperty { get { return m_MyValue; } set { m_MyValue = value; } } designer then autogenerates the following: myControl1.MyProperty = null;

    Read the article

  • LINQ display row numbers

    - by timvaines
    I simply want to include a row number against the returned results of my query. I found the following post that describes what I am trying to achieve but gives me an exception http://vaultofthoughts.net/LINQRowNumberColumn.aspx "An expression tree may not contain an assignment operator" In MS SQL I would just use the ROWNUMBER() function, I'm simply looking for the equivalent in LINQ.

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >