49 Posted Topics
How to check if a vector is NULL? [code=c++] vector <int> test; [/code] How to check if this is NULL? [code] if (test == NULL) [/code] returns compiler errors. | |
Hello, I am attempting to write the merge sort algorithm which will generate a vector of 20 random integers and then sort them. The problem is, it does not output the sorted list, it merely outputs a series of zero's and one's. My code is as follows, any help is … | |
Re: Hi, Your declaration of member functions is wrong in the test.cpp Should be like [ICODE]void Cool_Class::cool_function()[/ICODE] Also, it has been a while since I do OOP in C++ but I think you also need to declare a constructor, so the object knows how to exist... | |
Hello all, I am trying to understand the concept of pipe-ing input/output through a C program. I wrote this simple code: [CODE] #include <stdio.h> #include <stdlib.h> void in_read (int *foo) { read (0, foo, 1); } void in_write (int foo) { write (1, &foo, 1); } int main (int argc, … | |
Hello all, First off, I am not here to debate the merit of storing PDF as a blob in MySQL. I know this is not optimal solution, but this is the requirement that I have to work with. The upload appears to be successful, (Field in the database is filled … | |
Hello, everyone, Next semester, I will be taking a course in Java programming language, and was wondering if anyone knew of a good IDE that runs in the Red Hat/Fedora environment. (Preferably something installed through YUM.) I tried a Google search on this, yet the only thing I seem to … | |
I have this code. pthread_create does not through an error message, however it does not execute it's argument function. See comments in code for better description [code=c] void * moveFiles (void * arg); int main (int argc, char **argv) { pthread_t * tid; int rc = 0; /*variables count and … | |
Hello, I am trying to read through a UNIX directory in C and write all the filenames to an array. However, the array is not being populated with any value. Here is a snippet of relevant code: [code=c] char **files = {NULL}; struct stat fileinfo; int count = 0; int … | |
*EDIT-I know strtok doesn't actually 'return' a segfault-I realize after submitting topic that is poor wording. Hello, I am having a problem with the C function strtok, as follows: [code=c] void function_name (char * cmd) /* Gathered from another function using readline. Assume 'ls -l' in this example */ { … | |
Hello, I am trying to structure query to execute MySQL fulltext search. I have creates simple table as follows: CREATE TABLE IF NOT EXISTS `entries` ( `id` int(3) NOT NULL auto_increment, `doc` text collate utf8_unicode_ci, PRIMARY KEY (`id`), FULLTEXT KEY `doc` (`doc`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ; And … | |
Hello, I have two different tables I need to extract data from. They are linked by a number, that is to say the value of the field 'number' in table 1 is the same value as the value of the field 'num' in table 2. I can select data from … | |
Re: Ah, well, if you are simply trying to print the results, it is very simple: [code=perl] if ($_ =~ /(foo)bar(baz)/) { print "$1 $2\n"; #Prints 'foo baz' from the pattern 'foobarbaz' } [/code] See? You can put groups of parentheses around certain parts of the regular expression to 'capture' them … | |
Hello, I am attempting to use JavaScript to 'highlight' text by changing it's background color: [code] <div id="foo" onMouseOver="highlight(this);"></div> [/code] In JavaScript: [code] function highlight (word) { document.getElementById (word.id).bgColor="blue"; } [/code] This produces no effect. I also have an onClick event in the same div, can I not have onClick … | |
Hello, I have written a 'predictive text' widget using JavaScript/AJAX. When user enters a string of letters into form, the list of possible matches is displayed under the form. This works well and good, now I am trying to make it so that when the user clicks on a certain … | |
Hello, I am new to PHP language, but not to programming or Regular expressions. I am using [code]preg_match_all ($pattern, $file, $matches)[/code] in my code, where $pattern contains two groups of capturing parentheses. I understand that each element of $matches[1] is an element captured by the first group of parentheses, and … | |
Re: [QUOTE=lastlight;1171848]Howdy all, If I comment out "use functions" and"&run_frunner" (a call to the functions package) it will display in a browser[/QUOTE] Based on that analysis, I would guess that there is an error in the run_frunner subroutine in your functions module-it could also have to do with how you called … | |
Hello, all, I am writing an x86 function that is called, with arguments, from a C program. Which registers does x86 store these arguments in? | |
Hello, Question regarding the connect function (in Socket), how to specify a specific port? The function only accepts two arguments, the socket and the ip. I have multiple devices on the same ip but different ports that I need to connect to, how to do this in Perl? Thanks. | |
Re: You need to pass the array as an argument to the function...when you call the function from main, give it the array as an argument. | |
Re: I think your problem with the user name is that you are using getline. Try just using [icode]cin >> name;[/icode], like you're doing with the password. As for reading the password in as *'s, as far as I know (though I could be wrong) there is no clean way to … | |
Re: Yes, it does. Vectors are part of the STL and should be accepted by any recent C++ compiler. | |
Re: Your question intrigued me, so I copied your code and got the same error. Your problem is with this [icode]if ($htmlFile == 'no file found')[/icode]. Instead of the == operator, use the eq operator. Your actual problem, however, is that this will only work for the first HTML file in … | |
Re: Try [URL="http://lmgtfy.com/?q=Gaussian+elimination+with+scaled+partial"]this[/URL]. | |
Re: Have you looked at NetBeans? I'm pretty sure it compiles with gcc/g++, and includes an IDE. | |
Hello, I am trying to send e-mail using Perl and Net::SMTP::SSL. However, I receive errors when running this script (example from documentation): [code=perl] #!/usr/bin/perl -w use Net::SMTP::SSL; sub send_mail { my $to = $_[0]; my $subject = $_[1]; my $body = $_[2]; my $from = 'me@gmail.com'; my $password = 'MySuperSecretPassword'; … | |
Re: Reading from a file in array context will get you all the lines in the file: [code=perl] @array = <$fh> #where $fh is your file handle [/code] If the atoms are in order (1, 2, 3) etc, and you need to get specific values from them, use split: [code] my … | |
Re: This is...really not that hard...The first function is basically one line manipulating the variable with the calculation you were given. The second function is the exact same thing but in a loop from lower bound to higher bound. | |
Hello all, I am trying to write a clustering algorithm where, given location of certain points (I.e, latitude and longitude) I need to choose 50 of these to be cluster centers such that the diameter of each cluster is minimized. To that end, I believe that the program should choose … | |
Re: On the whole namespace thing, yes, don't use namespaces, but you can do things like [icode]using std::cout;[/icode] at the top of your program so you don't need to put the [icode]std::[/icode] in front of every print statement. As for the OP, you asked no question, but your code is riddled … | |
Re: Sales is passed to the function as an integer, but in the line [icode]cout << sales[count];[/icode] you are treating it like an array. Add a [] to sales on line 36-this will ensure the function will treat sales as an array. | |
Re: If the name is being read in as a string, you can append to it using the + operator: [code=c++] std::string name; std::cin >> name; /*say, Robert */ name += ".txt." std::cout << name << std::endl; /* should print Robert.txt */ [/code] EDIT: And then you can open the file … | |
Re: On Ubuntu, you should be able to [code] sudo apt-get install cpan [/code] And then [code] cpan ModuleName [/code] And this should configure everything automatically. | |
Hello, I am writing a C++ program to find the largest such number such that the square root of that number is less than or equal to a fixed number, set by me, like this: [code=c++] #include <stdio.h> #include <math.h> int main (void) { long fixed, param, result; result = … | |
Re: I ran a quick test and had the same problem you did; it would only get the odd numbered lines. I do not have much experience with Tk, but I think second argument to insert must be scaler. Thus, this will get all your lines: [code=perl] #! /usr/bin/perl use Tk; … | |
Re: Syntax errors notwithstanding, what problems are you having? What happens when you compile and run the code? | |
Re: What exactly are you asking? Perl arrays are not like C++ arrays, they can grow and shrink in size dynamically. [code] my @array; [/code] This declares an empty array, whose size is zero. To add things to array, most common operations push and unshift. [code] push (@ARRAY, $VALUE); [/code] puts … | |
Ok, so I have to write two (OO) Perl modules. One the them, in one of it's subroutines, needs to call the constructor of the other module. According to my professor, this should be doable without the classes having working knowledge of each other. For example, if I have: [code=Perl] … | |
Re: Been a while since I've used that syntax, but I think it is supposed to be: [code=cpp] bool Data::operator [/code] | |
Hello, If I have code like such: [code=c++] map <string, map <string, int> > foo; map <string, map <string, int> >::iterator bar; [/code] How to access the value of the nested map? Normally I access a map's value like such: [code=c++] bar->second; [/code] To that end, I tried doing this … | |
Ok, I'm not sure if the above title made sense, here is what I am trying to do: Suppose I am writing a module that looks something like this: [code=Perl] package Whatever; use strict; use warnings; #constructor--will take one argument when called sub new { my $class = shift; my … | |
Re: You need to use == instead of = in your if statements. '=' sets the thing on the left equal to the thing on the right, == means 'is equal to.' | |
Hello, I am having some trouble reading data from a .txt file. I know that the file contains strings separated by white space. The problem is, I don't know how many strings there are, so I would like to go through the file one string at a time, and then … | |
Hello, How to call a function which takes dynamic array argument? That is to say, if I have: [code=C++] void fctn (int *a[], int n) { *a = &n; //do stuff with a. } [/code] How to call this in main? Must I have another array declared in main to … | |
Hello, I am trying to write the merge sort algorithm. My code is as follows: [code=c++] #include <iostream> #include <cstdlib> using namespace std; void m_sort(int list[], int temp[], int left, int right); void merge(int list[], int temp[], int left, int mid, int right); void mergeSort(int list[], int size) { int … | |
Re: The header file you want is <iostream>, not <iostream.h> | |
Hello, I am having trouble understanding the output of the following program: [code=C++] #include <iostream> using namespace std; int main () { int a[5][6]; int b, d; for (b=0; b<=5; b++) { for (d = 4; d >= 0; d--) { if ((b+d)% 4 == 0 ) { a[d][b] = … | |
So basically, my assignment was to write quick sort and merge sort using both vectors and arrays, and time how long it takes to sort the the arrays and vectors of various sizes. However, the code is producing inconsistent results. Sometimes it seg faults, other times it produces unfriendly messages … | |
Hello, I am trying to write the quick sort algorithm to take in an array of 20 random integers and sort them. However, it is producing weird output for the sorted list. My code is as follows, can anyone give me a little help here? [code=C++] #include <iostream> #include <vector> … |
The End.