Hello Daniweb,

I'm currently working on a pretty straight-forward AJAX application. In this application, I get some XML, and then parse it. An example of what I'm working with is as such:
[code]
<?xml version="1.0"?>

athlon32 Hello World

[/code]

Now, I've been able to read the XML with [icode]XMLHttpRequest[/icode], my trouble is with parsing the results. I've tried tons of things, but I just can't seem to get the different child nodes.

Now, let's say we have something like this:
[code]
var xml = xhr.responseXML;
var allPosts = xml.getElementsByTagName('post');[/code]

Could I use [icode]childNode[/icode] to access [icode]user[/icode] & [icode]content[/icode]? And if so, how? I've tried many things, but nothing is working :/ Is there a better way to parse the results I get back from the server?

Anyways, thanks in advance. I'm sure this is really simple, but I'm a C coder just trying Javascript for the first time, so I'm kinda lost. :)

I have a function in a Lua script, that will take a file and and will work on it. Part of the work it does is to empty the file completely before working with it. The easiest way I know of doing this is to open the file with [icode]io.open[/icode], and use the [icode]"w+"
[/icode] parameter. The problem is that I always need to have the path to the file. I wanted to do this:
[code]io.open(thefile, "w+"); -- here thefile is a file object[/code]

but of course, that doesn't work. I need a way to get a file path in Lua. Anyone got suggestions? Sorry if I posted this in the wrong forum :/

Hello all,

I recently was reading some code and i found something along the lines of this:
[code="C++"]void GetText() {
int* size = new int;

// .......
// lots of code here
// .......

size = new int;

// crap here
}[/code]

^^ as you can see size is 'new'ed twice without being deleted. My question is, does this cause a memory leak? or does the first memory allocated get replaced by the second 'new'.

Thanks in advance :)

Hello Daniweb!

I'm coding a small application and I've hit a road block. I've been using C++ for almost two years now, but to be honest, I hardly use dynamic polymorphism (i prefer static), and so with great embarrassment, I come here to ask this:

My code is basically structured like this. I have a base class that many derive from, and it has 'common' functions that are virtual (of course :P). Any ways, there is another common function, but in each of the sub classes, it has a different return type. Now, i thought that if i have a 'Base' pointer, that pointed to allocated subclasses, I could still access non virtual functions...but of course i can't...so my question is, what do you do in a situation like this?

[code=C++]
// this is now my code is structured :D

include

class Base {
public:
virtual void Common() {} // a function common to all sub classes
};

class Class1 : public Base {
public:
int GetValue() { return 1; } // same as Class2 but int
};

class Class2 : public Base {
public:
char GetValue() { return '2'; } // same as Class1 but char
};

int main() {
Base* b = new Base;
b->Common(); // ok
delete b;

b = new Class1;
*b->GetValue(); // error!
delete b;

b = new Class2;
*b->GetValue(); // also error!
delete b;

return 0;

}[/code]

Thanks in advance :D

[QUOTE=Violet_82;1106261]Hi there, I am new to C++ and trying to get my head around it. I am writing really simple and small programs and I have Visual C++. Now, can anybody summarize how I can run a program I wrote with C++ on Visual? The guide that comes with the product doesn't seem to be that helpful, so I was just wondering if you guys can help me/telling me where to find a simple guide on how to run my own programs.
Thanks[/QUOTE]

Open Visual C++
goto File > New > Project...
select win32 Console app
name it
click next
now it'll give you a project settings page...
check 'Empty Project' and uncheck 'Precompiled Headers'
click Finish

ok...now goto Project > add new item
select .cpp file, name it, and make it
paste code in, and press F7 to build your code. Press shift+F5 to run your program.

I just learned about linked lists, so i decided to experiment a little. I'm trying to make a linked list that automatically keeps all of the data in consecutive order (like bubble sort built in :P).

Anyways, the problem is that while it adds data, the second thing added disappears, and IDK why :|

Here's the code:

sortlist.h
[code="C++"]#ifndef SORTLIST_H_INCLUDED

define SORTLIST_H_INCLUDED

template
class sortlist {
public:
sortlist() { bottom = NULL; }
sortlist(typename T dataToAdd);
~sortlist() {}

    void printall() { for(node* x = bottom; x->next != NULL;) { std::cout <<x->data<<"\n"; x = x->next; } }
    void add(typename T dataToAdd);

private:
    struct node { typename T data;
                  node* next;
                } *bottom;

};

template
sortlist::sortlist(typename T dataToAdd) {
bottom = new node;
bottom->data = dataToAdd;
bottom->next = NULL;
}

template
void sortlist::add(typename T dataToAdd) {
// if list is empty
if(bottom == NULL) {
bottom = new node;
bottom->data = dataToAdd;
bottom->next = NULL;
}

// iterate shall we?
else {
    node* iter = bottom;    

    while((iter->data < dataToAdd) && (iter->next != NULL)) {
        iter = iter->next;  
    }

    node* newdata = new node;
    newdata->data = dataToAdd;
    newdata->next = iter->next;
    iter->next = newdata;   
}

}

endif // SORTLIST_H_INCLUDED

[/code]

main.cpp
[code="C++"]#include

include "sortlist.h"

using namespace std;

int main() {

sortlist<int> ll;
ll.add(34534);
ll.add(789);
ll.add(344);
ll.add(344);
ll.add(466);
ll.add(654);

ll.printall();

std::cin.get();
return 0;

}[/code]

anyone see what's wrong??? :?

I can imagine, i mean i only payed like $300 for my PC. oh well, maybe i can upgrade soon :P

Intel GMA 4500M graphics, with up to 797MB total available graphics memory

I know a little DirectX 9(I can draw a little, etc.), but i want to learn DirectX 10. I decided to take the tutorial that is provided in the DirectX SDK, so i did.

Almost immediately i noticed that it was heavy. My CPU usage shot up and it took much longer to load than DirectX 9. The second example (drawing a simple triangle) took over twenty seconds to complete! My PC ain't the 'newest' so to speak, so i can see why i seem to be encountering these problems.

So what I'm asking is this: What can i do to make DirectX 10 work more smoothly on my rather weak PC? and what is the best alternative to DirectX? maybe OpenGL?

Thanks for the suggestions :) Never thought about it that way :)

Example of how to get a random number in the range of six and return a value based upon it. Please Rate/Comment/Report Bugs

This is just a little example of howto make a Gtk+ application go fullscreen. This is really useful in game programming. Please rate/comment/report errors :icon_mrgreen:

This is a good example :) 5 stars!

I've been learning DirectX, and overall, I'm really happy, it's not to hard and i can do tons of stuff. Now that I'm on more advanced things like meshes, i've run into a couple questions that i needed answering.

  1. What is a good free program for making meshes? (One that isn't blender; sorry, but I'm a 3D noob :()
  2. Can you use .obj files in DirectX, and if so, how? I have a great program, but it won't spit out .x files

I hope you people can help me :)

well, it sounds like what you really should be using is a dynamic container like a vector, or a list...arrays are good, but they tend to waste precious memory :)

I can understand if you're a noob, but vectors aren't hard at all:
[url]http://cplusplus.com/reference/stl/vector/[/url]

Hope I helped :)

[QUOTE=Silvershaft;937238]Thanks I got it now! Is there any way to make buttons look like well, modern button like circle like. I know it has something to do with style but where I put it :P

Thanks![/QUOTE]

These might help:
[url]http://msdn.microsoft.com/en-us/library/bb849169%28VS.85%29.aspx[/url]
[url]http://msdn.microsoft.com/en-us/library/bb775951%28VS.85%29.aspx[/url]

Try a synaptics driver?
[url]http://www.synaptics.com/support/drivers[/url]

Are you root or using sudo?

Hello There,

not to disappoint you, but upgrading isn't a good idea. It's better to jusr install the new OS on top of the old one, it'll get rid of all your programs, files etc., but it makes things much easier

make sure you backup all of your files!!!!

Hope i helped

[QUOTE=rockyman12;905673]Where can i start learning to work with l[B]inux[/B]

-Linux tutorials

  • ebooks

-Which distrubution do you recommend and why ?. (fedora, ubunto....)

  • And some other info

Ill apreciate any help and information

Thank you for taking an interest[/QUOTE]

[B]Linux Tutorials:[/B]
[url]http://www.lofwatlinux.com/[/url]
[url]http://www.linux-tutorial.info/[/url]
[url]http://www.ee.surrey.ac.uk/Teaching/Unix/[/url]
[url]http://www.linux.org/lessons/[/url]
[url]http://www.linuxplanet.com/linuxplanet/tutorials/[/url]

[B]Ebooks[/B]
[url]http://linuxebooks.com/[/url]
[url]http://www.onlinecomputerbooks.com/free-linux-books.php[/url]

Ubuntu Linux 9.04 - It's easy for beginners, but is also one that is very suitable for more experienced users too

or

Debian Lenny - A little more in depth if you will, but gives you a lot of control in my opinion

Hope I helped :)

[QUOTE=abhi.navale;903923]I have vista basic preinstalled in my laptop.
I want to install FIRST windws XP over VISTA and THEN Linux over XP.
So my pc will have three os like this:

  1. Vista
  2. XP
  3. Linux

will it work?
will linux recognise xp and vista and allow me to choose among three of them?
How to do it?[/QUOTE]

Make a partition for XP, install it on there, and then do Linux. Linux will probably resize the partitions properly :D

Hope I helped :)

[QUOTE=tux4life;903334][B]>"->" is used to access data members on the heap[/B]

The arrow operator [B]->[/B] is used to access data members (of a class) via a pointer, these data members do not necessarily have to be on the heap

[/quote]

I see, thanks for clearing that confusion up for me...I learn something new here everyday :)

Like u8sand said...use "."

[code]using namespace std;

include

class COne{
protected:
int a;
public:
bool is_equil( COne & other){
if ( a == other.a)
return 1;
else
return 0;
};
int seta(int val){
a = val;
return 0;
};
};

int main(){
COne a, b;

a.seta(5);
b.seta(3);

cout << "result is: " << a.is_equil(b) << endl;
b.seta(5);
cout << "result is: " << a.is_equil(b) << endl;
return 0;

}
[/code]

"->" is used to access data members on the heap :) hope i helped :)

[QUOTE=MosaicFuneral;902598]All the tobasco sauce I just drank. I can't fell my tongue.
Does that answer your question?[/QUOTE]

ROFL

Welcome to Win32 :) As long as your compiler/IDE supports Win32, and has all the includes (windows.h, etc.) It'll work. In my opinion the best compiler is Code::Blocks ([url]http://www.codeblocks.org/[/url])

[quote]if I can just start coding right away or do I need to download libraries etc[/quote]
probably not :)

Hope I helped :)

I think if you have the choice, either Ubuntu Server Edition
[url]http://www.ubuntu.com/products/WhatIsUbuntu/serveredition[/url]

Or Debian (if you don't mind setting everything up by hand LOL)
[url]http://debian.org/[/url]

If you're ok with paying a little money, you might wanna look at redhat as well

Hope I helped :)