WolfPack 491 Posting Virtuoso Team Colleague

What is this about?

WolfPack 491 Posting Virtuoso Team Colleague

Hi,
I want to know about C++, How do I declare a constant (like C++ const) in Java(tm)

const int contant_var = 10 ;

and how do I declare enums (like C enum) in Java(tm).if any one knows about this reply me
Thanks in advance

enum

WolfPack 491 Posting Virtuoso Team Colleague

I think the problem has to do with your corrupt user account settings. The vcsetup.exe file which you downloaded extracts the setup file to the TEMP folder, but then it can't seem to find the path of the setup.exe file.

To check, Enter %USERPROFILE%\Local Settings\Temp in the Run Dialog Box (Windows Button + R ) and press enter. If it says that it can't find the path, then the settings for your temp folder is incorrect.

I think you can solve the problem by changing the location of the TEMP environment variable as follows.

  1. Click on the Start menu, choose Run and type sysdm.cpl
  2. Click on the Advanced tab and click the Environment Variables button at the bottom
  3. Double-click on the User variable named TEMP and change it to any path on your drive
  4. Double-click on the User variable named TMP and change it to any path on your drive
  5. Double-click on the System variable named TEMP and change it to any path on your drive
  6. Double-click on the System variable named TMP and change it to any path on your drive
  7. Click OK to officially change these environment variables
WolfPack 491 Posting Virtuoso Team Colleague

Can you post the link/web page that you are downloading the file from?

WolfPack 491 Posting Virtuoso Team Colleague

I think you are using the "Run" option instead of the "Save As" option from the Download Dialog Box. First Select "Save As" and store it on your Desktop or somewhere other than Temp. After the download completes, run the setup file.

WolfPack 491 Posting Virtuoso Team Colleague

Did the download complete?

WolfPack 491 Posting Virtuoso Team Colleague

Come on Dani. We wouldn't be programmers if we didn't like tinkering with computers in the first place. Besides, even microsoft offers the option of switching between the the classic interfaces and the newly designed ones.

WolfPack 491 Posting Virtuoso Team Colleague

how do i compile a project with files/codes in a subversion..

suppose I have these files in a version control:

folder/implement.cpp
folder/head.hpp

I want to compile my main.cpp with these files

What I did is:

$ g++ main.cpp ../svn/folder/implement.cpp -I ../svn/folder/ -o main

It doesnt work...

Pls give me link that gives the complete codes on how to compile diff programs in c++.

tnx in advance...

I have not used subversion, only cvs and visual source safe. But they do not store source files using the usual file extension. They append a ",v" part at the end.
At any case, developers do not link the files in the repository directly. First they checkout them to a working folder and do the stuff from there. So first see if the ../svn/folder/implement.cpp file exists. It is likely that it doesnt exist, and what exists is a file like ../svn/folder/implement.cpp,v . If the ../svn/folder/implement.cpp,v exists, check the files to a working folder and build using them.

WolfPack 491 Posting Virtuoso Team Colleague

Are you using C or C++ ?

Ok getline is C++.

Maybe you can hack something out of the examples in this link.

WolfPack 491 Posting Virtuoso Team Colleague

Think of people like poor Christina here, who isn't happy about the extra scrolling involved with the larger size. It seems silly to make her scroll twice as much just to make bigger some text which is repeated twice on the same page, once already in the larger font size.

OK OK. I can bear with it for one week.

WolfPack 491 Posting Virtuoso Team Colleague

Dani can you make all the text sizes the same? I find the current font size too large ( I dont like scrolling, and I write my code at editor font size 9-10, but that is just me ). So when I change the size of text to suit me at daniweb, the quotes cannot be read as they are about two sizes smaller than normal text.

WolfPack 491 Posting Virtuoso Team Colleague

Without knowing the type of emails you are getting, it is difficult to pinpoint the cause. But usually you get so much emails because of the notifications that you get when someone replies to a thread that you replied.

You can disable it by setting the "Default Thread Subscription Mode" in this link to "Do not subscribe" or "No email notification"

WolfPack 491 Posting Virtuoso Team Colleague

I:*Dani

WolfPack 491 Posting Virtuoso Team Colleague

damn 30 second man, your starting to piss me off.. you have to reply to everything I say.. and it's always some dumbass remark again. Yes, I do know what nihilism is.. it is the belief in NOTHING. I believe there is NO purpose to life whatsoever, and no proof for a god... So I'd appreciate it if you would stop asserting that everything I say is wrong, when in fact, it's just you being a dumbass again.

I too think you are contradicting yourself. How can your believe in Nihilism when you believe in Nothing? You believe in Something!:rolleyes:

WolfPack 491 Posting Virtuoso Team Colleague

ouptputfile.txt should contain only derdfddderd which the last output isn't ?!

It should contain all the outputs for all the inputs the user enters.

dede
d
derdfddderd

1 more question is it right to read from buffer straight away?
for example
buff[200]
buff will constain the abab so i'll read the buffer and replace the characters with the second characters

If the output is correct, it doesnt matter how you do it.

WolfPack 491 Posting Virtuoso Team Colleague

Say for example your program name is replace.exe. Then you call that program with three command line options.
Example. replace.exe abc def outputfile.txt Then the program will read user input line by line and write the output to outputfile.txt.

e.g

[U]input [/U]                         [U] output[/U]
            abab                            dede
            a                               d
            abracadabra                     derdfddderd

I think the NB part is simple to understand. If you dont please say.

WolfPack 491 Posting Virtuoso Team Colleague

Here is the part of the code it applies to...

if( textBox2->Text = " " )
{

Shouldn't you use a == instead of a single = P.S.
If that doesn't work, then you will have to use a function like strcmp or an equivalent in Managed C++.

WolfPack 491 Posting Virtuoso Team Colleague

Spelling mistake.
The correct one should be iostream

WolfPack 491 Posting Virtuoso Team Colleague

How about using grid[ 0 ] = 'o';

WolfPack 491 Posting Virtuoso Team Colleague

>What is your favorite DaniWeb feature?

The Ads, they're so intrusive and they give me a warm and fuzzy feeling when they pop up in my face.

Awww.

:lol:

I'd say the syntax highlighting code tags.

WolfPack 491 Posting Virtuoso Team Colleague

Not that there's "gotta be somewhere for the ad" but remember the smaller quick reply box made way for one fewer rectangle ad.

I don't even remember the previous ads. Neither do I pay much attention to the present one. I don't even know what is the product you advertise in there, and what it is used for. The only reason I paid any attention was because I saw in some previous threads that it was the reason for the quick reply box to get smaller. And the reason I replied was just because you asked what I would change if I could, and not in the hope that it would get any larger.

And you seem to have missed the "with more formatting buttons" part.

WolfPack 491 Posting Virtuoso Team Colleague

I would change the quick reply box into a larger one, with more formatting buttons.

WolfPack 491 Posting Virtuoso Team Colleague

I have a little annoying problem and I really need help.

I need to convert a char* to TCHAR* and I can't... I have tried everything and nothing seems to help...

TCHAR text1[ ] = "";
char *key;

key[0] = 'a';
key[1] = '\0';

text1 = _T(key); //Does not work

can anyone help me here? I'm stuck

char *key;

key[0] = 'a';
key[1] = '\0';

This should give you a segmentation fault.

Do this.

char key[ 2 ]; // or char* key = new char[ 2 ];
 
 key[0] = 'a';
 key[1] = '\0';

As for the _T macro, maybe you haven't defined the _UNICODE macro.

Put

#ifndef _UNICODE

#define _UNICODE 
#endif

at the beginning of the code.

Oh and from what I know, doing TCHAR text1[ ] = ""; , and then assigning key to it should also give you problems.

WolfPack 491 Posting Virtuoso Team Colleague

I need to use emacs to compose an algorithm for counting the number of lines and words in a text file.


The words may comprise of any printing characters and are delimited by spaces and/or tabs.


Also the presence of any control character other than tab, eol (end-of-line), or a single terminating eod (end-of-data), I have considered an error, whereupon the algorithm should terminate.


I will need to give two levels of pseudocode before I create the program.


I then need to enclose my solution to in a comment block and implement my algorithm in C. I need to include comments with your code and I can’t define any other function than main.


Finally I need to devise a test file that serves to adequately test my program.

Heh. This looks like a school assignment with the word YOU replaced with I.

WolfPack 491 Posting Virtuoso Team Colleague

Well, looking at the documentation for midiOutSetVolume, I see that there is a

MMSYSERR_NOTSUPPORTED The function is not supported.

error value that can be returned when using that function. So maybe that is the reason in your case also. But the only way is to check the return value of midiOutSetVolume.

Use the following piece of code for that.

MMRESULT  res =  midiOutSetVolume( hdev, 0x0000) ;
    wprintf( L"midiOutSetVolume: " );
    switch ( res )
    {
    case MMSYSERR_INVALHANDLE: 
        wprintf( L"The specified device handle is invalid.\n" ); 
        break;

    case MMSYSERR_NOMEM:     
        wprintf( L"The system is unable to allocate or lock memory.\n"); 
        break;

    case MMSYSERR_NOTSUPPORTED:     
        wprintf( L"The function is not supported.\n" ); 
        break;
    case MMSYSERR_NOERROR:
        wprintf( L"success.\n" ); 
        break;

    default:
        wprintf( L"Undocumented Return value.\n" ); 
        break;
    }

If the function is not supported, I don't think there is anything you can do about that...(Not sure though) Anyone who has a better idea please answer.

Anyway remember to check return values when you use an API function. Return values are there for a reason.

Also, I don't see the reason for this piece of code.

DWORD abc;

       devCaps.dwSupport = MIDICAPS_VOLUME|MIDICAPS_LRVOLUME;

       abc = devCaps.dwSupport;
       if (devCaps.dwSupport == MIDICAPS_VOLUME|MIDICAPS_LRVOLUME)
       {
              wprintf(L"abc");
       }

You should check the value of devCaps.dwSupport after the call to midiOutGetDevCaps .

midiOutGetDevCaps(0, lpCaps, sizeof(MIDIOUTCAPS)); 

       if (devCaps.dwSupport == ( MIDICAPS_VOLUME|MIDICAPS_LRVOLUME ) )
       {
              wprintf(L"Left and Right Volumes Supported\n");
       }
WolfPack 491 Posting Virtuoso Team Colleague

A WORD is 16 bits. So both the right and left channels have a range from 0x0000 to 0xFFFF. To make a DWORD, you have to use the MAKELONG macro.

WORD leftChannel = 0x0010 ;
WORD rightChannel = 0x00FF ;

Do

DWORD bothChannels= MAKELONG ( leftChannel , rightChannel );

and pass bothChannels to midiOutSetVolume( hdev, bothChannels) But the actual device may not support all 16 bits that can be set for a channel.

It may help if you post the location of the original example.

Better keep an eye on this too.

WolfPack 491 Posting Virtuoso Team Colleague

Okay then. post the code, and the results you get for same input in different operating systems.

WolfPack 491 Posting Virtuoso Team Colleague

You should google more. This link has this explaination.

VIEWING THE IMAGE:

The file Images/r2s.c will create sunraster header. It can be prepended
to the raw data files to convert them to sunraster format. To use
r2s.c, compile it (cc -o r2s.c r2s), and then type
r2s 256 256 > head
cat head imagefile.raw > imagefile.ras
which will create a head file for a 256x256 sunraster file and prepend
it to the raw image file....

So find the Images/r2s.c file and compile it. If you can't find it in the internet, try emailing Fisher (if he can be contacted by email), and ask for the source file.

WolfPack 491 Posting Virtuoso Team Colleague

If you had compile errors, post the code and the compile errors. Otherwise you will only get generalized answers, saying this or that may be the problem.

WolfPack 491 Posting Virtuoso Team Colleague

First of all, remember to post the relevant error messages when you have a problem.

Compiling your program under VC 2003.Net gave me the following error messages.

perfect_nos.cpp(21) : error C2660: 'perfTest' : function does not take 0 arguments
perfect_nos.cpp(22) : error C2660: 'factorPrint' : function does not take 0 arguments

So that means you are not passing the required arguments to the functions. The line numbers where the errors occur are 21 and 22.

if(perfTest()=true)
       factorPrint();

While correcting them, I noticed that you are doing

if(perfTest(Fact)=true)
factorPrint(Fact); // This is what i called the functions

It should be corrected like

if(perfTest(Fact)==true)
factorPrint(Fact); // This is what i called the functions

The full corrected code is as below.

#include <iostream>
using namespace std;
bool perfTest(int Num);
void factorPrint(int Num1);
int  main()
{
    int num;
    int Fact;

    do
    {
        cout << "How Many Numbers Would You Like To Test? ";
        cin >> num;
    }
    while (num<=0);

    for(int a=1; a<=num; a++)
    {
        cout << "Please enter a possible perfect number: ";
        cin >> Fact;
        if(perfTest(Fact)==true) 
            factorPrint(Fact); // This is what i called the functions 
    }
    return 0;
}
 
// First Function ===============================
 
bool perfTest (int Num)
{
    bool perfect;
    int B=0;
    for(int A=1; A!=Num; A++)
    {
        if(Num%A==0)
        {
            B+=A;
        }
    }
    if(B==Num)
        perfect=true;
    else
        perfect=false;
    return perfect;
}
 
//second function ===============================
 
void factorPrint(int Num1)
{
    for(int A=1; A!=Num1; A++)
    {
        if(Num1%A==0)
        {
            cout << Num1 << ":" << A << " ";
        }
    }
    return;
}
WolfPack 491 Posting Virtuoso Team Colleague

argv[ 0] is the program name. You can see the contents by using this line

printf( "%s", argv[ 0 ] );

To get the first argument, and convert it to an integer, try this code.

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    int seconds = atoi( (argv[1]) );
    printf("%d", seconds);
}
John A commented: Good to see you around, Wolfy --joeprogrammer +8
WolfPack 491 Posting Virtuoso Team Colleague

Does the above function even compile? I see an undefined variable called value and a missing semicolon after value++ .

WolfPack 491 Posting Virtuoso Team Colleague

try this. It is for VC++ 2003.NET but I don't think there is much difference. You should be able to get an idea of what to do. Click on the images to enlarge them.

And you don't have to register VC to be able to compile applications.

WolfPack 491 Posting Virtuoso Team Colleague

For someone with almost 400 posts, you should have known better to explain what is going wrong (like post error messages), rather than just ask for help. If you compiled this program, you would have found that the variable vowel is not defined. Define it, initialize it to 0 , and the program should work.

WolfPack 491 Posting Virtuoso Team Colleague


My client is on wingoze

What is wingoze? Whatever it is, it may be an Operating system, and there should be a socket API for it. Look that up.

Salem commented: random rep++ from salem +6
WolfPack 491 Posting Virtuoso Team Colleague

RikaiChan Japanese-English Dictionary.

WolfPack 491 Posting Virtuoso Team Colleague

Without knowing the actual socket API that you are using, or the kind of socket that you are using, it is difficult to pin point the exact error. But most probably like the above replies say, a memory leak seems to be the best guess. The tools that you can use to detect the memory leak also depend on the OS you are using, so without that it is hard to guide you on that aspect. In case you are using windows, without going for any extra tools, try looking at the Task Manager-->Performance--> Memory Usage window. As time passes, if the memory usage line increases and stays at a maximum point for a while before the client crashes, then you can be sure that it is a memory leak.

By the way, come to think of it, are you writing the data that you recieve into the hard disk, or are you keeping it all in memory? If you are keeping it in memory, then your system must have run out of memory. Memory leak or not.

Posting the OS, Socket API and code if possible will certainly help in getting more accurate answers.

WolfPack 491 Posting Virtuoso Team Colleague

I must say that the size of the quick post reply box is more annoying than having to scroll past an advertisement to reply.

But since this change was the result of user request, I guess we will just have to train ourselves to click the advanced reply button. At any case, we have to click it after the reply gets more than 5 lines in length..

WolfPack 491 Posting Virtuoso Team Colleague

Use the strrchr function to search for the last occurrance of the backslash '\' character. If there is no match strrchr returns NULL, that means no path was returned in szFile, and all the contents of szFile is the filename. If there is a match, the contents from the starting position of szFile upto the position returned by strrchr is the path name. The rest is the filename. Try it yourself and post your attempt.

WolfPack 491 Posting Virtuoso Team Colleague

This is easy.
The letter E.

mattyd commented: the letter "E" +4
WolfPack 491 Posting Virtuoso Team Colleague

No point in going through a discussion on C++ books while this thread exists.

WolfPack 491 Posting Virtuoso Team Colleague

Thanks for the links. I changed my TERM variable from xterm to xtermc and that did the trick. setenv TERM xtermc emacs -nw

WolfPack 491 Posting Virtuoso Team Colleague

Try searching for interprocess communication in C/C++ and see if that is what you want. The actual method of implementation will depend on your operating system.

WolfPack 491 Posting Virtuoso Team Colleague

Repeat?

WolfPack 491 Posting Virtuoso Team Colleague

Correct. Now you.

WolfPack 491 Posting Virtuoso Team Colleague

I am working on Solaris 9 and using the emacs editor version 21.4. The problem is that when I use the emacs -nw command and turn the font-lock-mode on, I don't get the syntax highlighting by color like in the XWindow mode. The syntax highlighting is only done by bolding or by background coloring. The list-colors-display command also gives a blank window. I know that the terminal supports colors because when I use the ls --color command, the directories and executables are displayed in blue and green. Any idea on how I can get colors for emacs in the nw mode?

WolfPack 491 Posting Virtuoso Team Colleague

What do you throw away when you use it, and pull towards you when you don't need it anymore?

WolfPack 491 Posting Virtuoso Team Colleague

Moon?

WolfPack 491 Posting Virtuoso Team Colleague

you should try this.

perl -p -i.bak -e 's/\\n/\n\n     /ig' good.txt

It edits the good.txt file and creates a good.txt.bak backup file. Remove the .bak part in the above command and the backup file wont be created.

WolfPack 491 Posting Virtuoso Team Colleague

Perhaps there's not better place than to learn than from the creator of the language, that is, Bjarne Stroustrap.

Small correction, those are not written by Bjarne Stroustrup. Good books though.