~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Windows works with backslashes "\" and forward slashes "/" but you better use Backslashes.

And also looking at your "command string" dump i can clearly see the problem. YOu are passing something like "copyA.txt B.txt" which is not the correct syntax fro the DOS copy command.

The actual syntax is "copy source dest" with spaces present in between. You can find the syntax for all commands here
http://www.easydos.com/copy.html

For testing purpose try out inputting
YServer.txt as the first input and server.txt as the second input and watch what output is displayed.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

So where is your int main (void) function and what problems are you facing with this code, and if facing compile time problems mark the line which flags the error in red so taht we can see it and if run time error then describe it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

add

char a='"';
strcat(a, copier);
strcat(copier, a);

hahaha.. compile error!

Umm... buddy, what exactly are you trying to do. strcat funtion expects you to supply both parameters as char* ie char pointers and you supplying it a char.

You can get its prototype here: http://www.cppreference.com

Post your complete program from start to finish with the header files and then maybe i could pinpoint the mistake.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I dont get you...
Are you saying even after making the changes you get a syntax error ???

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
cin.ignore();
cout << "Enter lecture notes/tutorials location.\n";
cout << "e.g C:/Lecture Notes/lecture01.ppt";
cout << ">>>";
getline(cin,lectut_loca);
cout << "Enter lecture notes/tutorials name: ";
cout << "e.g lecture01.ppt";
cout << ">>>";
getline(cin,lectut_name);
string copy = "copy";
 copier = copy + " " + lectut_loca + " " + lectut_name;
// using variable before declaring it is not allowed in your case copier.

 const char *copier; // initialisation of const variables must be done 
                            // during declaration intself eg. const int i = 8 ;
 cout << copier;
 getch(); // getch() is non portable use cin.get ()
system(copier);
cout << "\nLecture notes/tutorials added.";

what should i do?

Look at the things i have mentioned above.
And maybe you should look at this simple expample.

string my_copy = "copy" ;
my_copy += " " + lectut_loca + " " + lectut_name ;
const char* copier = my_copy.c_str() ;
system (copier) ;

Hope ti helped, bye.

PS: looks like you are trying to implement the copy function of DOS.
;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe you can try out something of this sort and make it more robust and suiting to your own purpose.

using namespace std;
int main()
{
     int number=10;
     int your_number;
     char answer = 'y';

    do
    {
        cout<< "\nguess the number: ";
        cin >> your_number;

        if(number == your_number)
        {
            cout<<"\nCongrats!";
            cout<<"\nWant to try again? ";
            cin >> answer;
        }
       else if (your_number > number)
       {
            cout << "\nYour guess is a bit too high " ;
        }
       else if (your_number < number)
       {
            cout << "\nYour guess is a bit too low " ;
       }
    }
    while (answer == 'y');
    return 0;
}

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Though i dont know what exactly blackjack is but i think this is wat u want.

#include <iostream>
using namespace::std;

int main()
{
    char cards[13]={'2','3','4','5','6','7','8','9','0','J','Q','K','A'};
    char deck [260] ;    
    for (int i=0; i< 260; i++)
         deck[i] = cards [i % 13];        
        
    for (int i = 0; i < 260; ++i)
        cout << i << "  " << deck [i] << endl;

    cin.get () ; // use this funciton for making the screen stop
    //system("PAUSE"); dont use OS functions
    return 0;
}

Sorry if this is not what you were looking for.

hoosier23 commented: nice! +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you want a third party library for interfacing between C++ and TCL then maybe you should look here
http://cpptcl.sourceforge.net/

As for your second part of the question you havent as such mentionend what exactly is ICE otherwise i would have definately said something.

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try using an global variable instead of passing one

Yes i completely agree with Mr. Grunt, passing global variables is not the best programming practice around. And to suggest this to someone who has just started programming is not a good thing since they dont know the side effects or bad effects associated with them.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Why not just try to complete the assignment in Turbo C. In the help section of turbo C there is a small tutorial which explains how to setup graphics in Turbo C along with a small example.

And just copy pasting the files wont do the job coz Turbo C is not the same as Borland C++, i hope you get the point.

Maybe you can look here
http://www.daniweb.com/techtalkforums/thread11617.html
and
http://bdn.borland.com/article/16170

Hope it helped, bye.

Salem commented: Are we at 5 yet? - Salem :) +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'm new to these forums,and really new to C++,but here is what i need to know.I made a simple calculator in C++ and i was wondering what i need to be able to keep useing it without opening the program everytime...

// simple calc
// Chris Wilson
#include <iostream.h>
int main()
{
    float first;
    float second;
    float oper;
    float output; 
 
 
 
    cout << "|--------------------|\n";
    cout << "|-----Chris_Calc-----|\n";
    cout << "|--------------------|\n";
    cout << "|---------by:--------|\n"; 
    cout << "|----Chris_Wilson----|\n"; 
    cout << "|--------------------|\n"; 
 
    cout << "Would you like to:\n";
    cout << "1)add\n";
    cout << "2)subtract\n";
    cout << "3)multiply\n";
    cout << "4)divide\n";
    cin  >> oper;
    if (oper==1)
    {
                cout << "enter a number to add\n";
                cin  >> first;
                cout << "enter another number to add\n";
                cin  >> second;
                cout << "you get\n";
                output = first + second;
                cout << output <<endl;
    }
    if (oper==2)
    {
                cout << "enter a number to subtract\n";
                cin  >> first;
                cout << "enter another number to subtract\n";
                cin  >> second;
                cout << "you get\n";
                output = first - second;
                cout << output <<endl;
    }
    if (oper==3)
    {
                cout << "enter a number to multiply\n";
                cin  >> first;
                cout << "enter another number to multiply\n";
                cin  >> second;
                cout << "you get\n";
                output = first * second;
                cout << output <<endl;
    }        
    if (oper==4)
    {
                cout << "enter a number to divide\n";
                cin  >> first;
                cout << "enter another number to divide\n";
                cin  >> second;
                cout << "you get\n";
                output = first / second;
                if (first > second)
                cout << output <<endl; …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Post your attempt and we will definately help you out on topics on where you got stuck. Just giving out the source code would do you more harm than good.

Salem commented: I agree - Salem +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

For absolute beginners, i would recommend "C++ in 21 days" and if you want to move ahead from the beginner stuff i would recommend "C++ programming language".

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Listen, I don't speak c++, I don't really care what you c++ rabis debate about evry day.
In school we do Pascal , Pointers don't come into play until 1st year university.
Thanks for the advice anyways,
Ishwar

Frankly one sentence, PLEASE APOLOGIZE THIS INSTANT.
It really hurts when someone goes to the length of wasting his precious time and effort to help a newbie get his path right and all they get is this. Just put urself in our shoes and you would know what i am talking about. I wont adopt the aggressive attitude of Mr. Wolfpack and Mr. Salem and say sarcastic things coz i dont think i have the knowledge set they possess.

Even if you didnt like the anwer or have that PASCAL thing in your head, you could have atleast pretended that the answer helped you than throwing out things like "i really dont care". One thing you should keep in mind that no one in this forum is bonded to this forum in any agreement and formal sort of way. Its just a voluntary service all the people here provide so that newcomers dont have to go through all that these experts had to go through and show a path of correct and precise thinking.

Just think about it and you would know what you may have wanted to said and what you actually ended up saying.

Grunt commented: Nicely Said [Grunt] +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

~s.o.s~
You will need a cast.

So should i use the <const_cast> ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

std::string.substr() returns another std::string.and you can't mix C and C++ like that. you would need to allocate space for the substring

char * str = NULL;
string str2 = "hello";
string str3; 
str = (str2.substr(2,4)).c_str();

Mr. Dragon, wont this work or do the same trick or the const nature of the returned null terminated char array pose some problems ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Err.. buddy , it would be best you not resurrected dead threads. It would be really good if you just looked at the date of the last reply of a thread before posting in it. And by the way, the thread has been marked solved so please dont post in such threads.

Salem commented: Well said - Salem +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe you can do a workaround like this

#include <iostream>
using namespace std;

class Mine
{
    char pattern [6][30] ;

    public:

    Mine ()
    {
      char buffer [6] [30] = {"      #####        ",
                                        "     #     #          ",
                                        "    #       #         ",
                                        "   #       # #       ",
                                        "   #       # ##     ",
                                        "   #               #   "
                                        };

        for (int i = 0; i < 6; ++i)
        {
            strncpy ( pattern [i], buffer [i], 30);
        }

    }

    void display ( )
    {
       for (int i = 0; i < 6; ++i)
       {
           fputs (pattern [i], stdout);
           putchar ('\n');
       }
    }

};

int main (void)
{
    Mine me;
    me.display ();
    return 0;
}

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe something like

#include <iostream>
using namespace std;
class hello
{
private:
    char array[4][5];
public:
    hello();
    void get_hello()
    {
        cout << "From the function: array[2][2] = " << "'" << array[2][2]  << "'" << endl;
    }
} hi;

hello::hello()
{
    for (int i = 0; i < 4; ++i)
    {
        strcpy ( (array[i] ), "####");
    }
        cout << "From the constructor: array[2][2] = " << array[2][2] << endl;
        (*this).get_hello();
}

int main()
{
    hi.get_hello();
    cout << "\n" << "Press Enter to end this programm";
    cin.get();
    cout << endl;
    return 0;
}

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

POsting your code properly means :

1) List the basic logic and the purpose of your program ie what it is supposed to achieve.

2) List the unexpected behaviour that your program is displaying and if you are getting errors list the log file of errors.

3) Properly indent the code to make it desirable to read.

4) Enclose the code in

and

tags while posting your code.

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That's the same as my code, except that my code splits it into 8-byte blocks... Thanks for your reply, but unfortunately it didn't help.
Greetz, Eddy

Can you please post the output you are getting as well as a bit briefing on the feat you are trying to achieve and the program specifications ?
Maybe then i can try to do somehting.

Hope i am not asking too much, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe this would help you finding the actual fault in your program:

void encipher(unsigned int num_rounds, unsigned long* v, unsigned long* k) {
    unsigned long v0=v[0], v1=v[1], i;
    unsigned long sum=0, delta=0x9E3779B9;
    for(i=0; i<num_rounds; i++) {
        v0 += ((v1 << 4 ^ v1 >> 5) + v1) ^ (sum + k[sum & 3]);
        sum += delta;
        v1 += ((v0 << 4 ^ v0 >> 5) + v0) ^ (sum + k[sum>>11 & 3]);
    }
    v[0]=v0; v[1]=v1;
}

void decipher(unsigned int num_rounds, unsigned long* v, unsigned long* k) {
    unsigned long v0=v[0], v1=v[1], i;
    unsigned long delta=0x9E3779B9, sum=delta*num_rounds;
    for(i=0; i<num_rounds; i++) {
        v1 -= ((v0 << 4 ^ v0 >> 5) + v0) ^ (sum + k[sum>>11 & 3]);
        sum -= delta;
        v0 -= ((v1 << 4 ^ v1 >> 5) + v1) ^ (sum + k[sum & 3]);
    }
    v[0]=v0; v[1]=v1;

}

Hope it helped, bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I thought i would help but am getting this output.

Starting to get XTEA key
XTEA Key:
Characters put inside buffer
Original buffer:        ◄♣¶
orig casted:            ◄♣¶
Encrypting...
finished encrypting...
encrypted:              -ÿ
ä-
starting to decrypt...
finished decrypting, value of retbuf:
end of decrypt:         ╥ÿφ4╩╠≈⌠½½½½ε■ε■
Decrypted:              ╥ÿφ4╩╠≈⌠½½½½ε■ε■
Size of encrypted string:       10

Is this what you are getting ?
Just wanted to confirm.

Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe it's bull**** but as long as it is in the standards I can't deny it.

... and neither do you use it. ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

speed is sometimes much more important than modularity or maintainability. I worked several years on a program that had to get data real-time from barcode readers on packages as the packages moved along an assembly line. Then the program had to look-up data in a database whose key was the barcode, format the data, and send it to a large-character printer that would print information on the side of the packages when they moved past the printer. All that had to be done in less than 1/2 second and management thought that was too slow. We even resorted to assembly language to squeeze out every millisecond we could.

Thats exactly the point i was trying to put forward, but as i belong to the new generation couldnt find a real world example. Thanks, this was the kind of example i was looking for.

*but in the end these ppl will say that nowadays as the computing speed and memory has increased the optimizations dont matter. Well in this case the argument continues...*

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maintainability and readability are generally the 2 most important goals for any coder to aspire to (usually far more important than optimum speed & memory usage), its a good habit to get into.

Actully that is not true in all the cases.
For places or applications where the performance is of peak importance, optimum speed and memory do make a large amount of difference.

I dont mean that modularty is not important or you should go for speed more than modularity, just that it depends on the area of application in which the program is used.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I was not being rude, i just informed him that i did not ask that question, and restated my question Am I supposed to say 'yes that is what i asked', when it was not.

I very well understand that it was not your intension of being rude, thats why i went to the trouble of putting up the solution for you. I dont give a damn about rude people.
But what i said was not some kind of warning but just a reminder that including the word "please" would be more like it.

In case you dont know, the members of this forum are not bound in any way to help the people who post their problems here. Being actally polite and explaining the problem in depth would urge the people who see to posts to help you.

Hope you understand.
Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

@Lerner

Actually this is not what this guy wants.

He wants to pass the structure to the inbuilt qsort fucntion so that it is automatically sorted.

The technique for the above mentioned has already been posted by me.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I didnt ask how to refer to a specific member
I asked how do i pass to a proceudre

Please dont be rude when asking help. Such attitude wont fetch you any help. Mr. Lerner here is a senior member so restate your problem statement rather than asking just someone else to do it rudely.

BTW here is wat i think should suffice ur purpose:

typedef struct 
{
    char input;
    int value;
}List;

int compare (const void* source, const void* dest)
{
    List* listSource = (List*) source;
    List* listDest = (List*) dest;
    if ( (listSource->value) > (listDest->value))
        return 1;
    else if ( (listSource->value) < (listDest->value))
        return -1;
    else
        return 0;
}

int main()
{
     List myList[10];
     for (int i = 0; i < 10; ++i)
     {
         myList[9 - i].input = (char)i + 90;
         myList[9 - i].value = i;
     }
     for (int i = 0; i < 10; ++i)
     {
         printf ("\nThe list %d has character = %c and value = %d ", i + 1, myList[i].input, myList[i].value);
     }
     qsort (myList, 10, sizeof (List), compare);
     for (int i = 0; i < 10; ++i)
     {
         printf ("\nThe list %d has character = %c and value = %d ", i + 1, myList[i].input, myList[i].value);
     }
     getchar ();
     return 0;
};

If you dont understand any part just post again.

Hope it helped,
Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This makes the program a little more modular.

Well forgive me for butting in, but here modularity is not an issue since he is not building a Library module but a small program.

As far as writing normal programs are concerned the coder should always be concerned with the best and the fast implementataion wrt to both memory requirements and speed.

But still this is just me, I thought just wanted to let you know.
Any constructive criticisms appreciated.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Err.. you are getting it all wrong.

What i wanted to say was that even though i completely agree with the character shaping thing and all that but even the Super Mods and Dani should have the same view point otherwise it would jsut spell trouble for both of us.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thats what i intended to say, i definately agree but with other reputable people around....

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Err.. of course he wouldn't but looking at the way this thread is shaping up from "Your favourite beverage" to "Wolfpack making friends with Indians" Dani or some SuperMod would definately ban us all including wolfie :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Wow you sure do know a lot about Indian mantras at least enough to stump the non indian members.

But do you really know some good and useful ones which are used for praying the diety. Bring them on.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Going on Vacation in exactly 3 hours (8.30PM GMT 09th August)
Be back on the 21st August...
Say what you have to say, now.

Demons go to hell :)

quoted by Genzo Sanzo from Sayuki Reloaded (an anime)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Looks like I ~s.o.s~ will have to send sos sos sos (cry for help) to all my contacts of Daniweb. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Err.. eagles have wings.. remember *mere dost*.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Looks like you guys have really enraged teh WOLF with your recent commments so its better i take cover *ducks and is out of sight*

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Phew thats is a relief.

I had taken cover heeding goldeagles tip but have just come out hearing this. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ah ok you must be one of those that walks among us.

Now i am really starting to take Wolfpacks hint seriously. ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ooh thats 400 he he

Yeah for some its a stimulant and for some its a means of relaxation.

BTW wat you mean by your above statement.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Coffee for me.
One cup of hot steaming coffee and i am in seventh heaven.
Provides me with all the relaxation i need.

COffee anyone... ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you are using it for educational purposes then there are two options mentioned above by Mr. iamthwee.

And if using for some real application and u think that doing the swap without temporary variable would reduce the space required or the time then do think again. Its not that way. Current compilers are so optimised that using a temp varible doesnt even a fractiion affect the program.

But still if u are so peculiar about performance then usign Assembly Language is the way to go.

So u have two options:
1) use normal temp variable
2) use assembly language procedures

since using XOR and += have their own shortcomings.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hmm i can try it for u but it takes time so dont expect the ans to come in the minute u see this post. I will see what can be done. Maybe tomo i would be in a better frame of mind to think about your problem.

Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Better post ur effort along the guidelines which i have provided and then we will see where is ur code lacking and what needs to be changed. But first and foremost ur effort at solving the prob is a must.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

One way to do it is to create a struct called result like this

typedef struct result_
{
   int frequency;
   char* line;
} result;

And dynamically create an array of this struct to add the results found as well as the frequency of occurance. While getting every single line from the file comparisions have to be made with the temp array of struct and if a match is found to increment the frequency.

Mind u this method is very computationally intensive so think of some optimizations that can be made.

Hope it helped,
bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It would be really good if u could post the data file so that we can run the prog and see wat actually is the problem rather than assuming somethings.

Also if u are using C++ y not use string instead of character arrays.

Bye.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thanks for the feedback and i would really appreaciate if everyone would post any links to resources which are useful for C programmers so that they dont have to go any further than this thread.

hollystyles commented: Nice work to the hunter/gatherer of links +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The same program works fine with me.
Which OS and compiler (version) are u using?