Barefootsanders 0 Junior Poster

looks like your if statements are not being closed. make sure you close them properly i.e. whenever you have an open brace, {, it has a corresponding }. From a quick look you have 3 open braces without a matching closing brace.

hope that helps.

Barefootsanders 0 Junior Poster

If you understand the concepts and have written the insert function, then this should not be all that difficult to understand. Just for reference:

In an AVL tree, the heights of the two child subtrees of any node differ by at most one

So one solution would be to write a function that takes a node, at any given point in the tree, and can calculate its height (might involve recursion depending on how you determine it). Then you can pass child of the root to this function and determine if its a proper AVL tree or not.

Below is some scrappy pseudocode:
if heightLeftSubTree - heightRightSubTree is between -1 and 1
--this tree is an AVL tree
else
--this tree is NOT an AVL tree
end

Hope that helps (without giving to much away :) )

Barefootsanders 0 Junior Poster

Hey. Seems like you've made some progress. Thanks great! Below is my solution but as noted previously, there are many. Hope it helps!

/**
 * @file printV.c
 * @description Prints a V shape.
 **/

#include <stdio.h>

void printV(int);

int main() {
	printV(4);  // Change # to change the number of rows.
}

void printV(int numRows) {
	int i,j;
	int cols = (numRows * 2) - 1;
	
	char vChar = '#';
	char emptyChar = ' ';

	for(i=1; i <= numRows; i++) {
		for(j=1; j <= cols; j++) {
			if(i==j || i+j == numRows*2)
				printf("%c", vChar);
			else
				printf("%c", emptyChar);
		}
		printf("\n");
	}
}
Barefootsanders 0 Junior Poster

the answer is in the hint. I'll add that you need to use the hint for five loops, and for the last line use a separate set of three loops. The answer is right there. look at it again. It is not as hard as you think, I promise.
Each character in the line should have its own loop.

yeah, you could do it that way but it is highly inefficient. there is one way that you can do this using 2 for loops and a simple if/else statement. however codeguru_2009 has an even more efficient solution than mine.

Barefootsanders 0 Junior Poster

where will python reside? In server or client machine
Can you explain more? I have tried to understand what you want to do but I haven't got you well.

You can take a look at mysql module
http://mysql-python.sourceforge.net/

sorry for the lack of info. it will reside on the back end. I'd like to keep my database updated with certain information queried from other 3rd party API's and i figured i could write a python script to accomplish this as well as other maintenance tasks. so the user would have nothing to do with it. it would just do all of the automated tasks i would program it to do.

hope that helps

Barefootsanders 0 Junior Poster

It would probably be easier to generate a small 'V' by hand and figure out what coordinates that the '#' lands on. Then you can decipher the pattern and come up with what you would need to be put inside the for loops. Sometimes it's easier to do things by hand just so you can visualize it.

Barefootsanders 0 Junior Poster

Hi all,

I have a php/mysql based site set up. I want to keep my database layer updated via a python script that will query some other systems, parse data and make the appropriate CRUD calls to my database. My question is might be a simple one but I'm wondering the mechanics of setting up this type of system. I've heard it's fairly common to have a python backend but I'm unsure on how to go about implementing this. Do I write the python scripts and set up a cron job to run at specified intervals or is there some other mechanism that can do this for me?

Thanks in advance!

Barefootsanders 0 Junior Poster

This code below will do the trick, but it's going to use a lot of memory to run this.
You are making 26 x 26 x 26 x 26 = 456976 combinations. Are you sure you want to generate all of these combinations? What are you trying to achieve this for?

Thanks so much. Thats exactly what I was looking for. I am sorta unfamiliar with PHPs type casting syntax. I'm trying to stress test a script i'm preparing and just thought this would be a cool way to do it as well as a way to test myself and learn more.

Thanks again!

Barefootsanders 0 Junior Poster

This is how I would do it:

$lower = true; //if you want lowercase letters
$t = 4;
$s = 1;
while( $s <= $t ) {
	$i = ( $lower ? 97 : 65 );
	while( $i <= ( $lower ? 122 : 90 ) ) {
		echo str_repeat( chr( $i ),$s ) . '<br />';
		$i++;
	}
	$s++;
}

That what you are talking about?

Well sorta.. It would basically generate all teh combinations of a set containing 'a' through 'z'. i.e. {a,b,c,...,z}. So it owuldnt just generate aa, bb, cc.. it would go through all the possible combinations with a as the first character then b as the second character and so on.. sorry if I was not specific enough in my initial post.

Barefootsanders 0 Junior Poster

Hi all. I'm attempting to output all of the possible combination from "a" to "zzzz" and I'm wondering if theres an easy way of doing that. As an example output would be ...

a
b
c
....
z
aa
ab
ac
....
az
ba
bb
...

and so on..

Is there a way to just have a binary or hex value, cast it as an ascii to get your first value, then increment it and cast it again.. and so on?

Any help would be much appreciated.

Barefootsanders 0 Junior Poster

If you are trying to get away from Microsoft completely and you plan on using Ubuntu for everything, you may want to look into KVM. Kernel-based virtual machine is built into Ubuntu's kernel and works quite well. You can check it out here:

http://www.ubuntu.com/products/whatisubuntu/serveredition/technologies/virtualization

If you're set on using VMware, I would suggest CentOS as your linux. It plays better with VMware because it's officially supported as an enterprise platform, and CentOS is really just a clone.

If you decide on CentOS, Auireon.com has a great article on installing the base system.

http://www.auireon.com/content/centos-rhel-server-installation

Good luck!

Thanks for the post! My main concern was setting up some way of accessing the system from my main desktop thats sitting right next to it. Would you have any suggestions as to how to access them remotely besides ssh? Sometimes I like having the actual gui :p

Barefootsanders 0 Junior Poster

Yes, i run my subversion code repository on an ubuntu VM installed inside of a Windows 2003 R2 server. I use VMWare Workstation as its all I really needed to install another VM instance. I don't know too much about VMware's licensing but for whatever reason it looked like the best license when I purchased it.

O, okay thanks. What I really want to is get away from MS completely and use Ubuntu server with vmware. I guess i'm gunna have to check out vmware and their associated apps and see which one works - thanks!

Barefootsanders 0 Junior Poster

VMWare and Ubuntu. It is all a matter of preference but I love debian and ubuntu is debian based but provides more features.

Thanks for the reply. Have you used ubuntu server + vmware at all? Do you suggest any vmware software in particular? I've been using ubuntu for years now and have used vmware workstation to monitor some local vm's but I havent set up a virtualized server inviornment yet so I wanted to get some suggestions before i dove in head first.

Barefootsanders 0 Junior Poster

Alternatively you can run it on a seperate thread.

That would be my first suggestion. You could also think about using pipe()/fork() and have one process listen for messages while the rest of your program executes.

Barefootsanders 0 Junior Poster

Hi all. I want to set up a small array of linux servers on a couple computers I have.. I'd like to use virtualization software and set up 2-3 VM's on each computer. I was wondering if anyone had any suggestions as to what software and OS to use i.e. vmware vs virtual box... ubuntu server vs centOS vs suse etc..

Any suggestions would be much appreciated.

Thanks

Barefootsanders 0 Junior Poster

Wow thanks so much for that. I thought you meant an actual abstract class, i.e:

abstract class foo {...}

One question though.. is there any significance behind the values of the constants or did you just arbitrarily pick them?

Thanks again.

Barefootsanders 0 Junior Poster

Hi all. I recently moved and in my new place my wireless router is way far away from the rest of my equipment that needs to be on the network i.e. desktop computer, xbox, NAS drive, etc... I'd like to run just one Ethernet cord into my room and set up a switch. I currently have two pieces of equipment, a very old d-link di-604 broadband router and a newer (yet still kinda old) linksys wrt54g wireless router. I'm wondering can either of those be used to set up a switch? If not, what sort of equipment should I get? Do I need a dedicated switch or can I use a wireless router with the wireless functionality turned off.

Any help would be much appreciated.

Barefootsanders 0 Junior Poster

As was noted before, they are superglobals, you can use them anywhere. However, I suggest that you don't. If you're going to go the OOP route then I would suggest abstracting dealing with GET/POST/COOKIE/SESSION variables to a class that deals with them specifically called Request or something along those lines that can appropriately sanitize/parse/etc.

Abstraction is one thing I'm not too advanced with.. Could you provide an example of what you mean by an abstraction layer using the GET/POST/etc... variables? Any help would be appreciated.

Thanks.

Barefootsanders 0 Junior Poster

You do not have to pass them as params. They can be used anywhere. Your example will work just fine.

O wow, sorry. I read your previous post wrong.

Thanks!

Barefootsanders 0 Junior Poster

Those are called superglobals and they will work inside a class. Also the way you called the method in the if statement is incorrect. I hope you know that.

FYI: _POST and _GET are part of _REQUEST. Make sure you use the specific request type. Using _REQUEST isn't the best thing to do.

Thanks for the response. How can I use them then? I'm going to assume pass them in as parameters? The only problem with that is that my program relies on $_GET and $_POST for program flow. What I'd have to do is pass them in before the HTML starts to set them and then just check them. Does that sound right?
And yes, I know the if syntax isnt correct.. Just threw up a quick example. Thanks though!

Barefootsanders 0 Junior Poster

Hi all. I have a current PHP script which checks a number of GET, POST, and REQUEST variables. These are currently in a top-down PHP file and these variables control the flow of the application. I want to convert file to a PHP class, create an object and then access the class functions to perform actions in my application. I'm wondering are there any problems with creating a PHP like this:

class foo {
    function __ construct() {
    }
    function fooBar() {
        if($GET['param1'])
            return 1;
        return 0;
    }
};

$obj = new foo();

And then in my other documents I can just check the value of fooBar via:

<?php if(fooBar()) {....} ?>

Now this isn't exactly what I'm trying to do but it illustrates it. Is this good? i.e. proper practice? If not, how can I accomplish what I'm trying to do.

Thanks.

Barefootsanders 0 Junior Poster

Hi all.. .I'm trying to use preg_split but I'm having trouble getting the regular expression I want.

What I have now is a long character string, upwards of 200 characters depending on user input. I'm trying to do is break up my string an array, each element in that array having 50 characters. But I dont want to use str_split because that has the possibility to break up the string in the middle of words. So I'd like to create a regular expression that will get at max 50 characters and end in a space and use the functionality of preg_split to accomplish this.

What my pattern looks like is this (and mind you I'm not all that good with regex...)

/.{1,5}(?=\s*)/

Like I said, should be any string 1-50 characters long with a space proceeding the last character.

Any help would be much appreciated.

Thanks!

Barefootsanders 0 Junior Poster

Hi. I'm just being curious here and wondering if anyone would know what type of technology could re-create the web based audio editor used on myxer.com i.e.

http://support.myxer.com/2007/06/01/create-ringtones-and-wallpapers-with-our-online-tools/

I'd be interested in attempting to re-create these tools just for kicks and to see how it works.

Thanks.

Barefootsanders 0 Junior Poster

Hi all,

I plan on desining a PHP driven site. I was wondering what people used in terms of a framework (or none at all). I've looked into ones such as Cake PHP but I'm just not sure whats out there and am looking for suggestions/comments.


Any feedback/input would be much appreciated.
Thanks

Barefootsanders 0 Junior Poster

Good start but there are numerous problems with your code. I added comments and highlighted them in red for you to see where you went wrong.
Also, one thing i would suggest is review how to properly format code. it is very hard to understand what your code is doing just from it not being formatted.

using namespace std;

// This is minor but you do not need a parameter when you declare functions.
// You just need the type i.e. isVowel(char) rather than isVowel(char character)
bool isVowel(char character);

int main()
{
char character;

cout << "Enter a letter, if it is a vowel this program will tell you" << endl;

// This bracket, along with its matching closing bracket, is not needed.
// I'm confused on why you added these in here.  Just remove them.
{
cin >> character;  // Good character input

// Your isVowel function returns a bool, not a string to print.  What are you trying 
// to display to the user?
cout << isVowel(character) << endl;

// When you evaluate bool functions in an if statement you do not need to do
// '== true', just do if(isVowel(character)) { <actions to perform> };
if(isVowel(character)==true)
}

// This function is correct but function definitions go before or after main, not in 
// the middle.
bool isVowel(char ch)
{	
		if('A'==ch||'a'==ch||'E'==ch||'e'==ch||'I'==ch||'i'==ch||'O'==ch||'o'==ch||'U'==ch||'u'==ch)
	
	return true;
}
else return false;
}

Also, i dont know what you are trying to output if the character is true. I would assume …

Barefootsanders 0 Junior Poster

I'm not familiar with servers but I if fork is anything like multithreading, it shouldn't affect the other process. As for the cin that doesn't bring your program to a halt, try the "GetAKeySyncState()" function from <windows.h>, but that only tracks key presses; if you play around with it you can take in strings though.

ahh, im programming in linx environment so i dont thinkt that will help.. thanks though.

Barefootsanders 0 Junior Poster

HI,

I'm trying to write an application in C++ that has two things - a TCP server (listen server) as well as a TCP client where it can send to other TCP servers. I currently have both parts set up simultaneously. I did this by calling fork() and having the listen server begin to listen in the child process and having the parent process prompt the user for input. however, this is where the program hangs. Because I am prompting the user for input via 'cin', its blocking the TCP listen server from receiving any messages.

So, I have a few questions. One, since I called fork(), why would cin block the TCP server? Arent they, in essence, two different programs? Also, is there a way do do a non-blocking 'cin' ? Do you have any other suggestions for other ways to successfully implement this?

Thanks!

Barefootsanders 0 Junior Poster

This should take care of it for you as long as you have a head pointer which I'm assuming you do otherwise how would you access your list?

~CList() {
	// Create a tmp node
	CNode node;
	while(node->next != NULL) {
		node = head->next;
		delete head;
		head = node;
	}
}
Barefootsanders 0 Junior Poster

Hi,

I'm trying to code a program that involves a double linked list. I have the linked list working but the information in the link list need to be shared between 2 different classes. Is it possible to pass a linked list as reference and manipulate it within the different classes?

i.e.

int main(void) {
    CList list;
    Class1 myObj1(list);
    Class2 myObj2(list);
    return 0;
}

class Class1 {
	public:
		Class1(CList* list) {
                    class1List = list;
                }
      protected:
           CList class1List;
};

class Class2 {
	public:
		Class2(CList* list) {
                    class1List = list;
                }
      protected:
           CList class2List;
};

I know this isnt 100% correct c++ but i just wanted to get the point of what I was trying to accomplish across. Is this or something like this possible? If not, what are my options?

Thanks!

Barefootsanders 0 Junior Poster

I'm writing a simple networking application. I'm using berkley sockets and was wondering if there was a way to enable the UDP w/ ACK option when setting up a udp socket. I know the UDP protocol has an field (in the options area) to enable it but I'm unsure on how to enable this in C++.

Any suggestions?

Thanks

Barefootsanders 0 Junior Poster

>However, I've realized this does not work because of the way arrays are addressed.
Nothing to do with it.
Your error is in the subscripts.

array[2] = array[1];
array[1] = array[0];
array[0] = result;

oo wow thanks a bunch. I've been working w/ matlab for to long and it starts with 1 rather than 0 when addressing an array.

Thanks again!

Barefootsanders 0 Junior Poster

Hey all,

I'm trying to use a 3 element array and keep it sorted. So when i get a new value that should be put at the start of the array, I shift values down in the array like this:

array[2] = array[1];
array[3] = array[2];
array[1] = result;

However, I've realized this does not work because of the way arrays are addressed. Is there anyway to do this via unary operators?

Thanks,
barefoot

Barefootsanders 0 Junior Poster

Hey all,

I'm trying to create a directory monitor that will watch a certain directory and print changes made to that directory. I was wondering if there were any C/C++ libraries that provide an abstract class to access the file system on any OS. I would like the program to be multi-platform and fast so C/C++ seems like the right language.

Any suggestions??

Thanks

Barefootsanders 0 Junior Poster

Ok i figured out what I was doing wrong. My popup div did not have an ID. But now I have another problem... The popup works when the mouse is over the parent link but when you go to choose one of the sub links, the onMouseOut is fired and the links disappear. Is there a way around this? Thanks.

Barefootsanders 0 Junior Poster

btw, popup is a nested div. Would that make any difference?

Barefootsanders 0 Junior Poster

hi
use javaScript as follows:
<a href="#" onmouseover="javascript:fun1();" onmouseout="javascript:fun2()">Links</a>
where inside fun1() put
document.getElementById("div_p").style.display="block";
and inside fun2() put
document.getElementById("div_p").style.display="none";
where div_p is id of "popup" tag
.....i hope it solves your problem.
if you find to do something like this in IE also plz put here...
have a nice time !!!

Hey,

Thanks for the help however I get an error when I attempt to run this code:

javascript

<script language="javascript">
	function displayMenu() {
		document.getElementById("popup").style.display = "block";
	}
	
	function hideMenu() {			
		document.getElementById("popup").style.display = "none";
	}
</script>

html

<div class="navigation">
	<h2>Menu</h2>
		<ul>
			<li>
				<a href="#" onMouseOver="javascript:displayMenu();" onMouseOut="javascript:hideMenu();">Links</a>
				<div class="popup">
					<ul>
						<li><a href="Link1.html">Link1</a></li>
						<li><a href="Link2.html">Link2</a></li>
						<li><a href="Link3.html">Link3</a></li>
					</ul>
				</div>
		</ul>
</div>

I get an "Object required" error within both of the function where document.getelementbyid... is.

Any suggestions?

Barefootsanders 0 Junior Poster

Hey all,

I'm trying to make a small menu popup via CSS. On rollover, the link should display another set of links below the link that the mouse is hovering on. The code Below works in FF but not in IE. Could someone help out? Thanks.

style.css

.navigation {
	margin: 0.5em; 
	padding: 0.3em; 
	border: 1px solid #C4C4C4; 
	text-align: left;
}
.navigation li a:link, a:visited{
	color: #545454;
	text-decoration: none
	
}
.navigation li a:hover{
	color: #72C32B;
}
.navigation li a:active {
	color: #545454;
	text-decoration: none
}
.navigation ul{
	list-style-type: none;
	margin: 0.3em 0 0.1em 0.1em;
	padding: 0em 0 0.1em 1em;
}

.navigation li .popup {
	display:none;
	background-color:white;
	background-style:solid;
	position:float;
}
.navigation li:hover .popup,
.navigation li:focus .popup,
.navigation li:active .popup  {
	display:block;
}
nav.html

<div class="navigation">
	<ul>
		<li><a href="Home.html">Home</a></li>
		<li>
			<a href="#">Links</a>
			<div class="popup">
				<ul>
					<li><a href="link1.html">Link 1</a></li>
					<li><a href="link2html">Link 2</a></li>
					<li><a href="link3.html">Link 3</a></li>
				</ul>
			</div>
		</li>	
	</ul>
</div>
Barefootsanders 0 Junior Poster

Hi everyone,

I'm in the process of designing a C# program and I needed some help with what I wanted to accomplish. Heres where I stand. There are 2 parts, a client and a server. The client has a database and within this database contains the filepath(s) of all the music on the client computer. What I want is the server to be able to display these filepaths and be able to stream a selected one over the net, through a browser, to another computer. Could anyone point me in the right direction on how to access the client side database from the server and stream the data from one client to another client? I'm guessing the server would have to have an IP to connect to and get the information from but I was wondering if anyone knew what topics I should look into within C# and/or any other information that you think would be helpful.

Thanks,
-Barefoot

Barefootsanders 0 Junior Poster

I'm pretty sure its getting stuck in one of the while loops for some reason but I cant tell why. Any help?

Barefootsanders 0 Junior Poster

Hey everyone,

I'm attempting to write a program that will pipe and fork to have a parent and child process. Then the parent writes numbers to the pipe and the child either multiplies or divides the two numbers. For some reason my file I/O isn't working. It's supposed to keep a log of actions etc. Below is the bulk of my code. Any suggestions to get it working would be very much appreciated. What it does now is write the child log, but not the parent or output log.

Barefootsanders 0 Junior Poster

Ive read through mysql 5.0 documentation, tried using REGEX, LIKE, and strcmp(s1,s2) and nothing seems to work. I was wondering if maybe I missed something in the documentation.

Thanks.

Barefootsanders 0 Junior Poster

Hey everyone,

I'm attempting to delete records within my database but I'm having problems writing the query. What I need to do is delete records from my database that, within a field in this record, have a substring that I will pass to the mysql command. So for example,

A table has one field called filePath.
Example records:
C:\New Folder\test.txt
C:\New Folder\test1.txt
C:\New Folder\test1.txt
C:\Other Folder\test.txt
C:\Other Folder\test1.txt
C:\Other Folder\test2.txt

I would like to send a command that will delete records within the table where a substring of the filePath field matches 'C:\New Folder'. In this case, the top 3 records would be deleted.

Anyone know the proper syntax for a statement like this?

Thanks in advance.
-Barefoot

Barefootsanders 0 Junior Poster

Hey everyone,

I'm trying to store file path's within a database. The problem I'm having is that the file path contains a backslash and when put into the database, it causes a problem. So I need to add an escape character into the string. I was wondering if anyone could help me out with this. I attempted to write a function that would iterate through the characters in the string and input a slash when it finds a slash, but the problem is that the string is a set size and I'm unsure how to add a new character into a preexisting string. Anyone have any suggestions?

Thanks,
Barefoot

Barefootsanders 0 Junior Poster

Hey everyone,

I'm attempting to write a directory monitor in java but I'm stuck. I'm trying to find something in Java that is like FileSystemWatcher in .NET but I don't think java does. From what I read is that you have to continually poll the directory for changes. What I would like to know is that are there any events raised when a changes are made so that one could catch and process them? If not, could someone explain how to simply poll the directory for changes?

Thanks
Barefoot

Barefootsanders 0 Junior Poster

Yea, if you started using IIS and then subsequently started WAMP, your wamp web server probably didnt start, only the mysql server started most likely. If you would like to run both, you can easly change the port for the apache server in the httpd.conf file. It should be around line 50, you will see "Listen 80". Change that to something like 8080 or 8888 and then restart. The only drawback will be that you will have to access your apache server on localhost:8080 or localhost:8888. The IIS server will be just localhost.

Hope that helps.

Barefootsanders 0 Junior Poster

Edit: well looks like you fixed it. No need for my reply :)

Barefootsanders 0 Junior Poster

Hey everyone,

I plan on buying a domain name/hosting from a web host but I wanted to see if anyone had some suggestions. I previously used godaddy.com and had a good experience but I have been checking out oneandone.com and it seems to look better. Does anyone have any other suggestions and/or links to sites that do comparisons among major web hosts?

Thanks,
-Barefoot

Barefootsanders 0 Junior Poster

Thanks a lot. That solved it right up. Thought I could get away without including it and just declaring it as an extern but I guess theres no way around it. Thanks again.

Barefootsanders 0 Junior Poster

Hey everyone,

I'm attempting to write a header file, example.h that will contain function declarations that will be defined in example.c. For some reason Its giving me an error when i do this

extern void mainMenu(node*);

Now node is a struct defined in another header file, should I include that as an extern variable as well?

Something like extern struct node; ??

Thanks for the help in advance.

Barefootsanders 0 Junior Poster

Thanks for the help. I searched FileSystemWatcher and found just what I need. Thanks again!