Prabakar 77 Posting Whiz

usb 2.0 is indeed very slow compared to 3.0 but all my devices other than the macbook pro don't support usb 3.0, so that's why I don't want to spend much money on nas adapters which support only 2.0. I am going to settle with this for a while and will upgrade all my devices later.

Prabakar 77 Posting Whiz

thank you

Prabakar 77 Posting Whiz

I have been posting in dani web during my college times, after being employed, I stopped posting in dani, now I updated my email id few weeks before & I am a unverified user. How can I become a verified user? and how can I get e-mails from dani?
Please advice

Prabakar 77 Posting Whiz

First I don't understand the need to clone trees, having same data in two different places often cause problems than solving problems. Do you have a reason to do so?

sink = NULL;

Do you really expect this to free the memory you allocated? If so, you may have to go and read your c book again

May be you'll have to check before you recurs again

sink->val = source->val;
if(source->left){
    sink->left = malloc(sizeof(tree));
    copy_tree (sink->left, source->left);
}else{
    sink->left = NULL;
}
if(source->right){
    sink->right = malloc(sizeof(tree));
    copy_tree (sink->right, source->right);
}else{
    sink->right = NULL;
}

Please don't PM for answers

Prabakar 77 Posting Whiz

HTML's are supposed to follow strict xml syntax (not all web pages do so) But the html that your have posted does follow xml syntax so you can use xml parsers and extract data from this. If the page is not xml complaint then you might have to use reg-ex pattern match to extract data. I used this when I first started with reg-ex

Prabakar 77 Posting Whiz

Yes, you are right, and then the device does have a wonderful review in amazon, http://www.amazon.com/review/R256QQ6DDFTJ8N/ref=cm_cr_pr_viewpnt#R256QQ6DDFTJ8N
and I am still searching for alternatives. Thanks again for your time, in helping me

Prabakar 77 Posting Whiz

Thanks for the reply.

I already have a linksys usb adapter with which I connect the pc to the router, not as good as the one you linked above, but at just $7 in new eggs site.

that nas adapter does suit my needs but then is a bit expensive.
So, I think I am looking for the right device. I'll post the device specs i'll purchase once I decide.
http://www.techchee.com/2010/01/23/silex-shares-usb-devices-over-gigabit-network/
http://www.newegg.com/Product/Product.aspx?Item=N82E16833996123&Tpk=Silex%20SX-3000GB
This one as of now seems to fit my budget and requirements very well, not sure of the quality

Prabakar 77 Posting Whiz

Hi,

Below is my home n/w status.

I have a modem which connects to a wifi router
1 laptop, 1 mac pro, 1 i-phone and a pc all which connects to this wifi router.

I have 2 external hdd & a printer which I want to connect to the n/w. I found that I need a nas adapter.

I did google and found a few device, which supports bit torrent download or pogo plug that connects them to internet, and so on. A few products I found are as follows.

http://www.techchee.com/2010/01/23/silex-shares-usb-devices-over-gigabit-network/
http://www.dealextreme.com/p/standalone-bittorrent-bt-client-upnp-usb-nas-ftp-samba-printer-sharing-network-lan-server-20383
http://www.addonics.com/products/nas/nasu2.asp - only one device at a time (Doesn't work for me!)

Can someone please give me some suggestions on what to look for, and which brands are good?

Thanks,
Prabakar

Prabakar 77 Posting Whiz

Hi All,

I need a software that would optionally let me open applications without the windows border, i.e, I don't want to see that blue border and the title bar for some of my applications(cause it spoils the appearance)

I am using Windows XP(32 - bit)

Is there any such tools existing!!?

Prabakar 77 Posting Whiz

Very nice:)

Prabakar 77 Posting Whiz

killdude69, the only way you could hold on to your argument is to talk on situations in which portability has no value. Say, while developing vertical solutions to a non IT based company which uses windows environment, there is no point in providing portability as a feature cause it means nothing to your customer(the customer uses only windows and wouldn't like the distribution of the software to other companies, as in the licence agreement)

In such cases, it is better to exploit tools provided by Microsoft, even if its exactly what Microsoft wants.

In the end its your choice. Be a slave to microsoft or not.

But, I much prefer programs that run on Linux than on windows cause I am a linux lover. Linux is a life saver to people like me who cannot afford to buy windows and who do not want to pirate:$

And you can't deny the fact that you were wrong when you said that you know the source code of win32 api.

To be ignorant is not a big problem, but not to be able admit mistake and learn from it is a problem.

Cheers:)

Prabakar 77 Posting Whiz

heh, how about a screen shot?

Now I am surprised too. Its not changing, $-)

Prabakar 77 Posting Whiz

Alright, now run it again. I'll bet you 20 fictional bucks that it won't output that exact same thing again :) (well eventually it will once every gazillion times or so)

prabakar@prabakar-desktop:~$ ./a.out
FOURFOURFOURFOURFOURONETWOFOURONETWOFOURONETWOFOURFOURFOURFOURONETHREEFOURONE
THREEFOURONETWOONETWOONETHREEprabakar@prabakar-desktop:~$ ONETWOFOURONETWOONETWOONETWOFOURFOURONETWOONETHREEONETWOONETHREEONETWOONETWO
ONETWOONETWOFOURONETHREEONETWOONETWOONETHREE
prabakar@prabakar-desktop:~$ ./a.out
FOURFOURFOURFOURFOURONETWOFOURONETWOFOURONETWOFOURFOURFOURFOURONETHREEFOURONE
THREEFOURONETWOONETWOONETHREEprabakar@prabakar-desktop:~$ ONETWOFOURONETWOONETWOONETWOFOURFOURONETWOONETHREEONETWOONETHREEONETWOONETWO
ONETWOONETWOFOURONETHREEONETWOONETWOONETHREE
prabakar@prabakar-desktop:~$ ./a.out
FOURFOURFOURFOURFOURONETWOFOURONETWOFOURONETWOFOURFOURFOURFOURONETHREEFOURONE
THREEFOURONETWOONETWOONETHREEprabakar@prabakar-desktop:~$ ONETWOFOURONETWOONETWOONETWOFOURFOURONETWOONETHREEONETWOONETHREEONETWOONETWO
ONETWOONETWOFOURONETHREEONETWOONETWOONETHREE

Now what was the bet? :D
To tell the truth I did not even care to read the program at first and I would admit that yes, indeed, I cannot assure that, it would be the answer every time.

Nick Evan commented: Here's 20 bucks :( +16
Prabakar 77 Posting Whiz

prabakar@prabakar-desktop:~$ gcc test.c
prabakar@prabakar-desktop:~$ ./a.out
FOURFOURFOURFOURFOURONETWOFOURONETWOFOURONETWOFOURFOURFOURFOURONETHREEFOURONE
THREEFOURONETWOONETWOONETHREEprabakar@prabakar-desktop:~$ ONETWOONETWOFOURONETWOFOURONETWOFOURONETWOONETHREEONETWOONETHREEONETWOONE
TWOONETWOONETWOFOURONETHREEONETWOONETWOONETHREE

I made those corrections stated by others

Prabakar 77 Posting Whiz

Why do you want to do that?
you can use structures
say

struct myFloat{
    short int sign:1;
    short int expo:6;
    short int mant:11;

    float toFloat(){
        // conversion 
    }

    // overloaded arithmetic operations

    // constructors and initializations
}

hope this helps:)

Prabakar 77 Posting Whiz

Oh, I am so dumb, I forgot to flush any unsend data from the socket.

It's working like a charm now.

Prabakar 77 Posting Whiz

Hi everyone,

I am a little new to Java programming and am doing a simple project. The Problem is that I am able to connect but am not able to send any data. It is a little weird. The server gets the client's IP and the client to is connecting to the correct port yet no data is getting transferred. Perhaps, I am over looking on something, that's why I end up here.

A Brief Description of what I am trying to do:

Monitoring system:
Monitoring system has a pool of threads. Each thread connects to one clustered server. The Job of these threads is to dequeue the request and send them to the clustered servers(something may be wrong here). The Main program gets requests from clients(end user) and queues them.(This part is working well)

Clustered Servers:
These are more like workforce, all they do is get a request and calculate the answer and send them back to the Monitoring System.

End User:
Just a simple application to send the requests and get back answer.

That's all about the project.

Here is a code from Monitoring System.

/** delegates Request to the Clustered server */
public class Delegator implements Runnable {
    int serverID;
    Socket socket = null;
    DataInputStream in = null;
    DataOutputStream out = null;
    FileInputStream fis = null;
    public Delegator(int serverID){
        this.serverID = serverID;
        connectToServer();
    }
    public void run(){
        while(true){
            if(defs.reqQueue[serverID].isEmptyQueue() == false ){
            RequestDetails reqDetails = defs.reqQueue[serverID].peekinto(); …
Prabakar 77 Posting Whiz

Paths must never be hard coded. You must get them from Shell.

That's what I always do, but, it looked like the OP was not satisfied with it.

What if he can't move it from a particular folder? ( happens often when it is a shared computer)

Copying the pdf and pasting it on a specific directory just to make your program work is not a good option

And adding the program to that directory might be irritating. It will be annoying to see a document in my songs folder.

Sometimes we need to use full address, or at least to use environment variables.;)

Prabakar 77 Posting Whiz

you can use strncpy() strncpy(a2, strings+4, 4); or you can just write a function that would copy 4 bytes from the starting address.
The latter is better, I think

Prabakar 77 Posting Whiz

Print MaxDistance to the console so that you can keep track of the stack. Then analyze the output.
Or, better, Debug it. I mean, run the program step by step and see how the variable MaxDistance changes and how the condition "something" and the assignment "something" works

Prabakar 77 Posting Whiz

I believe, this is a forum to help C++ programmers, not customers!

Oh, are you looking for C++ compilers, then Microsoft Visual Studio Express Edition is a good option

Prabakar 77 Posting Whiz

Same directory as the reader? Why not give the full address fo the file?

Like this,

ShellExecute(NULL, "open", "\"D:\\program files\\Adobe Reader 9.exe\"", 
				"/A page=45 \"C:\\Documents and Settings\\Prabakar\\My Documents\\Downloads\\How to Do Everything _ Ubuntu (McGraw-Hill).pdf\"", NULL, SW_SHOWNORMAL);
Prabakar 77 Posting Whiz

I do not have vista, to help you:( I don't know why it is not working in vista, these functions are ment to work on windows after all. Perhaps you'll have to wait for others to respond

Prabakar 77 Posting Whiz

>>programing is not for everybody... it requires LOTS of time to master

Well, if you ask me, programming is fun. And fun is for everybody.
So, If It requires a lot of time then its just that you are having a lot of fun.
>>the time you take to LEARN C can and most often will be frustrating
And if fun turns frustrating, Dani can help you out:)

>>There will be much larger walls to climb then this one

Yes, Much more fun

Prabakar 77 Posting Whiz

I believe, your real requirement, is to set variable precision for your floating point number.
If so
The bad news is you can't do it that way.
The good news is there is another way. printf("This is your value:%.*f", 4, 22./7); Follow the link to know how it works

Or are you looking for something like this?

#include<stdio.h>
#define st "String 2"

#include<math.h>
int main ()
{
  printf("Str 1 "st);//equivalent to printf("str 1 %s", st)
  return 0;
}
Prabakar 77 Posting Whiz

That's what I will do. But it is up to you.

Prabakar 77 Posting Whiz

Okay let me be brief,

1) Don't use conio.h
2) Don't use void main. int main is the standard way
3) so many if else statements? what if you need the diamond to be bigger. The following code is as good as yours

puts("    *");
  puts("   ***");
  puts("  *****");
  puts(" *******");
  puts("*********");
  puts(" *******");
  puts(" *******");
  puts("  *****");
  puts("   ***");
  puts("    *");

Here is a different way of doing it, in c

#include<stdio.h>
#include<math.h>
int main ()
{

  int i, j, n=5; // n controls the size of the diamond. 

  /*Remember that there is a restriction in the number of char the console window can put in a line, more than that the text will be wrapped messing up the diamond*/

  for (i=n; i>-n-1; i--){
    printf ("\n%*c", abs(i)+1, ' '); //Space to be provided
    for (j=2*(n-abs(i))+1;j;j--)
      putchar('*');
  }
  getchar();
  return 0;
}
Prabakar 77 Posting Whiz

no, int the main function you have initialized the char, then the short, then the int, Now if you initialize int or long first and then the short and byte, you will have a well defined behavior, just like the memset that salem suggested. That's what i ment

Prabakar 77 Posting Whiz

Uninitialized data can never ever be trusted. You are bound to get random values immaterial of the compiler you use and the processor you use. As Salem said. And if you have initialized the long int first(in which case all the bytes in the union would have been initialized) you will get the same answer on all computers that you compile the code, provided they all have little endian byte format or if they all have big endian byte format.

Prabakar 77 Posting Whiz

ummmm....
how can you giv print to a single variable var with %s specifier???

your problem shouldn't be in the code but the definition of var[]!

We don't know how it is declared, do we? It might be a 2D array or an array of Pointers or may be even vectors, the op should give more details if he/she wants a good answer

Salem commented: Yeah, that and many other possible horrors +28
Prabakar 77 Posting Whiz

If you know that there is a way, why not go for it, why should one try all the ways possible? If you are lucky you would have chose the right path the first time. I would go for DFS. I believe one should use a stack and not queue.

Prabakar 77 Posting Whiz

I don't understand why you expect the same answer.

You are assigning the chat a value 'a', i.e., 97 is stored in the first byte.
Now you are retrieving the value stored in 2 bytes(short), 4 bytes(int and long) so the garbage data will be taken and you are bound to get different values.

The second time the short will get the expected answer since you have assigned it a value, but in the event the char c gets changed to character 1 which is the smiley displayed(See Ascii table) and the int and long will still contain garbage value.

Perhaps you miss understood what union is. Google to know more about it.

Prabakar 77 Posting Whiz

Sorry to have suggested an untested code.
My little Google search found me this

Have a look at it.

This time I have tested the code and it really works.

ShellExecute(GetDesktopWindow(), "open", "\"D:\\program files\\Adobe Reader 9.exe\"", "/A page=45 Ubuntu.Pdf", NULL, SW_SHOWNORMAL);

D:\Program files\Adobe Reader 9.exe is the path to the portable reader in my computer(I always try to get portable versions).

Ubuntu.pdf was in the same folder as my CPP program, hence I did not specify its path.

Details about parameter options could be found int the link above.

Good Luck

marcosjp commented: Very helpful, saved my day with a great solution +1
Prabakar 77 Posting Whiz

The official way is with Win32 COM
(never use keybd_event, not professonal at all...)

I'll take a note of that.

And the actual answer is not either. Its just to give an argument to the pdf we are opening;)

Prabakar 77 Posting Whiz

EDIT:

On second thoughts, you are right.

Just a little change

ShellExecute(GetDesktopWindow(), "open", "c:\\someFolder\\myFile.pdf #page=4",  NULL, NULL, SW_SHOWNORMAL);

Just add a space, cause page=4 is an argument.

----------------
I don't know if there are any real ways to do it. But how about triggering some keyboard inputs with keybd_event()
All you have to do is Ctrl+Shift+N to open the "go to page" dialog box. and then the input the number 4(say) and also "Enter" with the same function. Before all this you have to give time for the pdf to get opened and become active(You may have to use the function Sleep())

You can get the complete set of Virtual key codes in msdn

Hope it helps

Prabakar 77 Posting Whiz

And you have to swap the elements to get the array in reverse order.

Prabakar 77 Posting Whiz

or did you mean to use x = lower + width * (i*25 + 0.5) ;

Prabakar 77 Posting Whiz

>>Room 1;
Did not you learn that variables start with alphabets and _?

Prabakar 77 Posting Whiz

>>isbn1, isbn2, ...
why not use isbn[10]?
And what are the contents of the infile?

Prabakar 77 Posting Whiz

First I thought this should be easy. But I am finding it hard to co relate the / & \ and the spaces according to the nodes present above.
The Input to my program is: 5738642
And the output is:

5
37
2468

EDIT: By the way I am using a search tree for simplicity.

Prabakar 77 Posting Whiz

For some reason the [/ b] tags did not work. Cant you at least remove it?
Did you really do that program?

Prabakar 77 Posting Whiz
int **a;
a = new int*[n];
for ( int i = 0 ; i < n ; i++ ) a[i] = new int[n] ;

to make it simple

Prabakar 77 Posting Whiz

oops sorry. Should have tested the code before posting it.
heres the code

#include <iostream>
#include <string>

using namespace std;

struct database {
  int id_number, age;
  float salary;
  string name;
};

void output_data(struct database*data_ptr)
{
  cout << "*********************************\n";
  cout << "name = " << data_ptr->name << "\n";
  cout << "id_num = " << data_ptr->id_number << "\n";
  cout << "age = " << data_ptr->age << "\n";
  cout << "salary = " << data_ptr->salary << "\n";
  cout << "*********************************\n";
}
void input_data(struct database*data_ptr)
{
  int i_tmp;
  float f_tmp;
  string s_tmp;
  cout<<"enter name:";
  cin >>s_tmp;data_ptr->name = s_tmp;
  cout << "enter id_number :";
  cin >> i_tmp;data_ptr->id_number = i_tmp;
  cout << "enter age :";
  cin >> i_tmp;data_ptr->age = i_tmp;
  cout << "enter salary:";
  cin >> f_tmp;data_ptr->salary = f_tmp;;
  cout<<endl;
}
int main()
{
   database *employee ;
   [B]int n;[/B]
   cin >> n ;
   employee = new [B]database[/B][n] ;
   for ( int i = 0 ; i  < n ; i++)
       input_data(employee+i);
   for ( int i = 0 ; i  < n ; i++)
       output_data(employee+i);
}
Prabakar 77 Posting Whiz

I have to leave now. But at a glance I saw that you use a strange way to print your rectangle class. Have you heard of friend functions? declare the operator<< function as a friend of rectangle.

Prabakar 77 Posting Whiz
int main()
{
   database *employee ;
   cin >> n ;
   employee = new int[n] ;
   for ( int i = 0 ; i  < n ; i++)
       input_data(employee+i);
   for ( int i = 0 ; i  < n ; i++)
       output_data(employee+i);
}

EDIT:
Also Use code tags properly. Like [code=cpp] and not just [code].
Intend your code for better readability.

Prabakar 77 Posting Whiz

Did not Nature give a wonderful explanation about making the pyramid. Did you try what Nature said?
Modify her code just a little to suit your problem.
Its as simple as

#include <iostream>

int main()
{
  using namespace std;
  int n;
  cin >> n ;
  for ( int i = 1; i <= n; i++ ) {
    for ( int j = 2*n-1; j ; j-- )
      cout.put ( j>(2*i-1) ? ' ' : 'X' );
    cout.put  ( '\n' );
  }
}

or perhaps this would do

#include <iostream>

int main()
{
  int n;
  std::cin >> n ;
  for ( int j=10,i = 1; i <= n; )
    std::cout.put ( j==2*n+9?j=10+(i++*0):j++>=(2*(n-i)+10) ? 'X' : ' ' );
}
Prabakar 77 Posting Whiz

Yeap, Copy the pointer to the first node. And move it to the last node and print the data as you traverse.
And did you really understand how your dequeue algorithm works?

Prabakar 77 Posting Whiz

>>while (x % answer != 0) answer++;
1) The code may be short but gives more work to the computer. You have to check if x is divisible by a number lesser than its square root and thats all you have to do. So In this case the while loop need not execute more than 10 times at the maximum.
2) What will happen if the input is 1?

Prabakar 77 Posting Whiz

I got 117 in Easy and 126 in hardest and I am going to join the society:)
EDIT:
One has to pay atleast 80$ to get the Membership:(

Prabakar 77 Posting Whiz

system ( "echo %USERPROFILE%") ; Will print the address.