506 Posted Topics
Re: Can you post your code? If you have implemented the search using recursion you won't need to store the parent info inside each node. | |
Re: [CODE]#include<stdlib.h> #include<stdio.h> #include<string.h> typedef struct linked_list_elem { char *val; struct linked_list_elem* next; } t_linked_list_elem; t_linked_list_elem* head = NULL; t_linked_list_elem* tail = NULL; // Finds given string in given linked list. // returns: the t_linked_list_elem matching the string if found, // NULL otherwise. t_linked_list_elem* findItem (const char* string); // If string … | |
Re: [CODE]public double averageAge() // calculating average age in each BMI group { double numbers[] = new double[this.list.length]; // KASH: You probably need an array to store // totals as well. One total per "cat". double result = 0; char[] cat = {'O', 'U', 'N'}; for (int i = 0;i < … | |
Re: Actually you're pretty far from linking trouble. You have major compilation issues. Few things you need to fix and remember: 1. DO NOT USE things like "Student", "iostream", "Name", "Date" as include guards. Make YOUR include guards unique. Qualify these names with your street address if needed. E.g. #ifndef student_Casper3912_myCountry_myCity_myStreet. … | |
Re: Is performance your concern? Without knowing: - What defines a grid cell? and - How you define "overlap"? I can give general comment that assuming to find out overlapping cells you'll have to compare all cells with all other cells, I suggest 1. some struct with better random access (vector, … | |
Re: Is your question how to use the regEx or where to do the validation? | |
Re: If you want fancy stuff [URL="http://www.java2s.com/Tutorial/Cpp/0500__STL-Algorithms-Non-modifying-sequence-operations/Useforeachfunctiontoprintallelementsinavector.htm"]use STL for_each[/URL]. So if you have 3 vectors to print then your code would look like this: [CODE=C++] vector<int> vec1; vector<char> vec2; vector<float> vec3; for_each (vec1.begin(), vec1.end(), print); for_each (vec2.begin(), vec2.end(), print); for_each (vec3.begin(), vec3.end(), print); [/CODE] Even if you don't want fancy stuff, … | |
Re: It would print something after demo3 IF you had written [CODE]e.printStackTrace(); // instead of e.fillInStackTrace(); // on line 56 [/CODE] | |
Re: None of [URL="http://www.google.com/search?q=reference+counting+with+smart+pointers"]these[/URL] helped?! | |
Re: You should first (before writing code) think what would the algorithm look like. I think it should look like this: [iCODE] while i've not printed 6 lines{ print next line } print next line() { required number of numbers to be printed = ??? while I've not printed required number … | |
Re: Have you already [URL="http://en.wikipedia.org/wiki/Bubble_sort"]read this[/URL]? | |
Re: Safest would be to have some shared variables between teh monitoring thread (one running main) and monitored threads (t1, t2). When the condition is met, monitoring thread sets the variable to indicate that monitored threads should exit now. This would give an option to t1/2 to gracefully shutdown. Also I … | |
Re: WaltP>> By the way, leave the computer alone until: I concur.. :) One other pointer I can give is to google up a bit on pre/post/in-fix notations and their use. | |
Re: In OOAD grouping of related attributes (e.g. FirstName, LastName, Title,..) is achieved by creating a class (say Person) and adding "FirstName, LastName, Title" as attributes/member-variables to the class. Now each instance of this class would have all the attributes. What you then do is create an ArrayList of Person. | |
Re: [QUOTE=Alpdog14;1511940]Can anyone guide me on how to create the tests for this?[/QUOTE] In eclipse, right click on the .java file and say New->JUnit Testcase.. :) Select the methods you want to test, then implement the methods. | |
Re: Did you read up anything on [URL="http://www.google.com/search?q=java+socket+example"]how to use sockets in Java[/URL]? First 2 results seem good enough.. | |
Re: [QUOTE=JamesCherrill;1513468]Windows: javaw -jar myJar.jar arg1 arg2[/QUOTE] Works only if MANIFEST has required mainClass entries. Can't assume all jars have it. I don't really understand what's the problem here. They've given you the command, which seems to be simple enough. Just run it! Call the script like this: [ICODE]xyz_script.sh C:\init_file.ini[/ICODE] | |
Re: A bit surprising.. It works for me even when VendingDisplay is defined in the cpp instead of header. The error that you said VS gives you "error:no instance of overloaded function VendingDisplay::VendingDisplay matches the specified type", which line number did it correspond to? When you do [iCODE]MyClassInstance1 = MyClassInstance2;[/iCODE] copy … | |
Re: Search..! Narue has posted many sorting [URL="http://www.daniweb.com/forums/search.php?searchid=15717592"]code snippets[/URL]: Not all are in C/C++ but you should get a hang of the algorithm at least e.g. - [url]http://www.daniweb.com/software-development/java/code/216339[/url] --edit-- And not to forget: [url]http://en.wikipedia.org/wiki/Sorting_algorithm[/url] A good [U]reference[/U] book is [URL="http://www.google.com/search?q=Introduction+to+Algorithms+Cormen"]Introduction to Algorithms[/URL]. | |
Re: As AD said you can't de-compile C/C++ compiled code. You can "re-package" a library only if it's static library, not dynamic. OP>> "I am using microsoft visual studios" Given what you're trying to do I recommend you export the makefile and have a look to see what's happening behind the … | |
Re: Don't forget to close the streams. | |
Re: Reposting the code so I can see it better. [CODE] #include<stdio.h> #include<conio.h> int main() { int no, line, i, j, k, m, end_of_part2, l, no_of_numbers; printf ("Enter number to get pattern up to that number.."); scanf ("%d", &no); for (i = 0;i <= no;i++) { for (j = 0;j <= … | |
Re: Can you send the command lines and the outputs with error? Also given that there is nothing "not-extern" in the headers you posted, the problem (repeated definition of...) can't be due to these as extern doesn't [I]define[/I] anything it only [I]declares[/I]. Hope you do know the [URL="http://www.daniweb.com/software-development/cpp/threads/131659"]use of extern[/URL]. --edit-- … | |
Re: You can start here: [url]http://en.wikipedia.org/wiki/Open_addressing[/url] | |
Re: You need to create a rule to convert .c (or .cxx, .cpp) file into a .o file. Something like: *.o: *.C gcc ... It's been 4 years so I forgot the syntax. :) But this bare-bone Makefile. You should be able to find an example from the gcc documentation itself. … | |
Re: [CODE]package com.kash; import java.util.Scanner; import java.util.StringTokenizer; public class TestMain { public static void main(String[] args) { int pos = 0; String input; Scanner s = new Scanner(System.in); int count = 0; while (true) { System.out.print("Enter a sentence: "); input = s.nextLine(); System.out.println("input = \"" + input + '"'); StringTokenizer str … | |
Re: [CODE]java TestDie[/CODE] If you're using eclipse. Right click on TestDie and say Run as->Java Application. PS: Usage of drivers is stone age. In the new world they use JUnits. | |
Re: [QUOTE=fsamu2001;1510415][CODE]#include<iostream> #include<string> #include<iomanip> using namespace std; //function prototype void sortData(string* ,int*); void calcAverage(int*, int); void displayData(string* , int*, int); int main () { // pointer variables string* name; int *score; int size; int counter; //dynamic variables // user enter score cout<<"How many test scores will you enter?"; cin >> size; … | |
Re: [QUOTE=programing;1510412]plz how i can delete a specific value in linkedlist ..[/QUOTE] [CODE] #include "the_code_that_I_wrote.h" int main() { //... create and populate the list here.. delete_specific_value(myList, specific_value); return 0; } [/CODE] In case it's not obvious, [ICODE]the_code_that_I_wrote.h[/ICODE] contains the implementation of [ICODE]delete_specific_value()[/ICODE]. | |
Re: Polymorphism is a side-product of good OO design. It's not something you design. What part do you want to make polymorphic? The drink? If yes, just create 10 subclasses of drink, one for each type and hardcode teh values you're passing in c'tors on lines 29-37. | |
Re: [QUOTE=griswolf;1510551]char is in fact a (very small) integer type. To convert the string of char to int, use atoi() or something similar.[/QUOTE] From atoi(3) " DESCRIPTION The atoi() function converts the initial portion of the string pointed to by nptr to int. The behaviour is the same as strtol(nptr, (char … | |
Re: 1. Where in your code are you actually checking if "a set was in alphabetical order to start with, and needed no rearranging."?? Currently your code is [CODE] ins.open("data.txt"); // input original data. while(!ins.eof()) { INORDER = set; // <<-- ... set++; // <<-- } ... cout << "NUMBER OF … | |
Re: Seems like when you do call the pedal(), it would return you the new position (say P1). But the next time you call pedal again, it would still give you P1. You should also call [iCODE]rollForward()[/iCODE] of both wheels inside pedal() to update required members inside wheel objects. --edit-- The … | |
Re: See [URL="http://en.wikipedia.org/wiki/Reverse_Polish_notation#Postfix_algorithm"]this[/URL].. Specifically this part: * It is known a priori that the operator takes n arguments. * If there are fewer than n values on the stack ** (Error) The user has not input sufficient values in the expression. | |
Re: ps supports and option "h" (not -h) that suppresses the header from getting printed. See "OUTPUT FORMAT CONTROL" section in "man ps". | |
Re: I would recommend Office VB script. Easy and powerful, takes a day or two to learn but has very wide application. | |
| |
Re: Space between -D and CORE is the problem [CODE=bash]$ gcc -o finame -DCORE="op1_log.txt" finame.c[/CODE] | |
Re: You can: - Define a struct that has time stamp and the whole string (as read from file) as members. - Define an array of this struct. - Write a function to read the file and populate the array. - Write a function that can sort the array of structs, … | |
Re: What is choice defined as? | |
Re: 1. Code you posted shouldn't be compiling as Object doesn't have getName(). 2. "However when I use this method it doesn't remove anything": How do you check whether something is removed or not? E.g. if you expect that the size of the array would change then know that it won't. … | |
Re: Simpler would be: [CODE] #!/bin/sh # usage: get_mount path # returns: mount pount of given usb path if [ $# -eq 1 ]; then df -h | awk /$1/'{print $6}' else echo "Usage: `basename $0` path" fi # One liner: # [ $# -eq 1 ] && df -h | … | |
Re: AFAIK there is no algorithm to get morse code given an alphabet. So you can not avoid a maintaining this mapping. But if you're using array(s) that's not so good. Use map. | |
Re: Here is the pseudo-code: [CODE] // Create an array of char*(s) // You might be forced to use a custom struct (see comments // below) if you want to control the memory usage. while (fscanf(myfile, "%s", str) != EOF) { // Extract each word (find index of next white space … | |
Re: At least read the output printed by your script ! woooee has been nice enough to add traces to your script, don't expect s/he isn't going to DO IT for you. HINT: How many times do you expect "[ICODE]print "comparing", s[index], s[-1-index], "for index", index[/ICODE]" to be executed and check … | |
Re: [CODE] public class DaniWebHelper { public static void main(String[] args) { String[] questions = { "Frequency count", "Stack and queue", "Conversion of infix to postfix using stack", "binary search tree" }; for (String q : questions) { String url = "http://www.google.co.in/search?q=QQQ+site%3Awww.daniweb.com"; System.out.println("Answer to \"" + q + "\":\n\t- Open a … |
The End.