Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't need either of those two programs. To edit a text file just completely rewrite it. Open the original for reading, open a new file for writing, in a loop read a line from the original file, edit it as necessary, then rewrite it to the output file (or just ignore it if you want to delete it). When done, close both files, delete the original file, then finally rename the new file with the same name as the original file.

There are no standard C functions that perform regular expressions. If you were using c++ then you could get such a library from boost

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are using VC++ 2008 (or earlier) you can easily view the entire contents of that buffer without resorting to putting that kind of debug code in your program. Not sure if Code::Blocks will do it too or not. If you are just using command-line compilers then you aren't working as efficiently as you could.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I'm new to using Visual Studio. I'm currently using VS .NET 2003 on Vista

Upgrade to VC++ 2008. You can get free Express version. CLR and MSDN was changed quite a bit since 2003.

Not sure why direct.h could not be found. Did you use angle brackets instead of quotes? such as #include <direct.h> Questions about WinPCap should be directed to their support group. We are in no position to provide that type of technical support.


inline VC++ 2008 supports inline only for C++ programs. In C programs using __inline

As for the last problem(s) you will need to post the entire file. If its pretty large then zip it up and attach it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

OMG! Is that some sort of failed attempt to sort the array??? There are lots of sorting algorithms, had you bothered to google for any of them. Like these.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Do you mean you read a c++ tutorial (you did NOT write it), and you want to know how to compile it? What compiler do you have? Each compiler is different.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you try deleting all object files and recompiling everything? If that doesn't work then post the offending source file.

NicAx64 commented: experienced can't be teached, it should obtained +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No worries ... we always love feedback so anytime you have anything to say, please be my guest ... and know that you're being heard. :)

Yea, right. Like you ignoring this thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are using MS-Windows then use win32 api console functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are no standard C or C++ functions that will do what you want. Bu8t there are some non-standard functions in conio.h, if that has been implemented by your compiler. You could also probably use something like ncurses library, or other win32 api functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've looked at the assembly code quite a bit and have found it contains very little "useless junk". But you can have it produce assembly code listing if you want. Look in the c++ options and there you will see it. Unless you want to hand-code the entire program you will not be able to change the assembly code that it produces.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Function add() -- second parameter must also be passed by reference. You are just passing the pointer by value, which does nothing in main()'s copy of the pointer. Note the second parameter should have two stars, not one.

int add(int* index, int **a)
{

}

lint 49: The typecast is wrong so you might as well just remove it because malloc() does not need to be typecast in C programs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 67: amic is an ininitialized pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>for(int i = 0; i < strlen(buffer); i++)

buffer is NOT a null-terminated string, so strlen() can/will not work with it. The buffer you created is just an array of characters, and memset set each byte of the array to the value of 0x01.

>>Why is it that when I use 0 instead of 1 in the above memset code, the buffer appears to have been wiped ou
Because the string functions in string.h all; use null-terminated string, and 0 is the same as NULL. So when you memset the buffer with 0 then you are telling strlen() and other string functions that the buffer is empty. strlen() returns the number of non-0 bytes in the buffer. It will scan the buffer until it encounters the first 0 byte, where-ever that may be. If you memset() the buffer with all 1s then strlen() will continuing looking through memory until it finds a byte whose value is 0.


>>as noted in my original post, everything past the pageFrameOffset appears to have been wiped from my buffer. The length of the array is much smaller when this happens.
That's because you are writing the binary value of the integer to the buffer, not the text value. Take the case of an integer whose value is 1. After memcpy() the buffer will contain (*nix operating system the bytes are in reverse order)
buffer[0] = 1
buffer[1] = 0
buffer[2] = 0
buffer[3] …

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

vector doesn't have a find() method. Maybe what you want is std::map instead of two vectors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can not convert an integer to character array like you tried to do. Use sprintf() instead sprintf(t, "%ld", i);

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) you failed to read Aia's comment.

2) The printf() statement is incorrect. %s is for a charcter array, shape is not a character array. What you want os %c

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Using TurboC++ is like riding horse&buggy on todays interstates or autobahns (in europe). Ditch the horse&buggy and get a free modern ferrari.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Now you are using yet another new object that you have not told us about. What is m_pVect2Grid?? Please refrain from introducing new objects without defining them for use.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First you have to define the term "microarray data". We are programmers, not biologists.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if (length=breadth)

you are using the wrong operator -- use == boolean operator instead of = assignment operator.

>> shape= 'square';
Two problems with that line

  1. All strings (two or more characters) have to be enclosed in double quotes, such as "square"
  2. variable [shape] can only hold a single character, such just do this: shape = 's'; . If you want shape to contain the entire string then redefine it as char shape[15]; and use strcpy() to copy it strcpy(shape,"square");
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are using a 32-bit compiler on either MS-Windows or *nix then forget those two functions because they are not implemented by any 32-bit/64-bit compiler. The operating system will not permit direct access to hardware or computer ports. You have to use normal operating system api functions. Those two functions were written for 16-bit MS-DOS which did permit programs direct access to hardware.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Vector2<float> m_pVec2Stage[150];
Most likely that line. vectors are by definition arrays. So all you probably need is this: Vector2<float> m_pVec2Stage; . But of course we can't be certain because we don't know how Vector2 was implemented.


The only reason I can think of to use the above construct is if yiou need a vector of vectors. In that case you would do this: Vector2< Vector2< float>> m_pVect2Stage;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 22 and 25: delete the = " " There is no value to initializing the strings with a single space.

line 25: delete that line because it has no value.

line 48: useless. What you want is to build a std::string object, then after the loop finishes insert it into the vector

   for(int i = 1; i < num+1; i++)
    {
      str1 = ""; // clear the string for new line 
      for(int j = 0; j < i; j++, n++)
        {
        str1 += chars[n%26];
        }
      myVector.push_back(str1);
     }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

cout only works with text buffers -- your buffer contains binary information and most likely the very first byte is a 0.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

simple colution

int main()
{
    int num;
    char chars[] = "abcdefghijklmnopqrstuvwxyz";
    cout << "How many strings do you want to create?\n";
    cin >> num;
    long n = 0;
    for(int i = 1; i < num+1; i++)
    {
        for(int j = 0; j < i; j++, n++)
            cout << chars[n%26];
        cout << '\n';
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

On my computer Alt+2 generages '☻', not ^B

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It should exchange the value of the two variable parameters. The two parameters are passed by reference so that swap() can change them and the calling function will see the change.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>is it a standard one?
Yes -- all compilers are required to implement it like that. Here is info about ansi c standards

>>the array name cannot be changed is it the standard or compiler dependent.
Standard -- its impossible to change the name of an object once it has been instantiated.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can solve for pc first in a similar manner that I posted. I think the problem in ComputerMove() is that if a square is already eith 'x' or 'o' you need to generate another random number and try again. At some point the computer is going to generate a random number for a square that has already been used. When that happes it needs to generate another random number. You already had such a loop coded but you commented it out.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It doesn't make a lick of sense to write a custom print function for every conceivable data type using printf() or fprintf(). cout, ofstream and ifstream already have overloaded functions that do it for you. And formatting can be easily done using cout or fstream class.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This minor change made it work when I move first

if (choice==1)                                  //if player wishes to go first
      { 
            bool done = false;
            do{ 
                cout<<"\n turn = "<<t<<endl;
                HumanMove(Board);
                w=CheckWin(Board);
                if (w==1)
                {
                    cout<<"Youwin!";
                    done = true;
                }
                else if (w==2)
                {
                  cout<<"You lose!";
                  done = true;
                }
                else if (t==9&&w==0)
                {
                    cout<<"Tie Game";
                    done = true;
                }
                if( done == false)
                {
                    PrintBoard(Board);
                    ComputerMove(Board);
                    w=CheckWin(Board);
			        PrintBoard(Board);
                    t=t+1;
                }
            }while(done == false);
      }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Oh I see -- I guess I misunderstood. You would have to sort the list after it was finished. When sorting linked lists just exchange the actual data, not the entire nodes, to preserve the link pointers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If all you want to do is run that program once when what' the point of making the text file into a fixed-length records? Such a scheme would limit the usefullness of your program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

where is your code? No one here will write that program for you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not really my "favorite", but Wanted is a very very good action movie. If you liked Die Hard you will also like Wanted.

I suppose my favorite was Dune. I wore out two tapes because I watched it so many times.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what compiler are you using? I compiled/ran with vc++ 2008 express and your first program worked ok.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Change AddWord() to add the new node in ascending or descending order. Then you won't have to bother about sorting later.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) remove conio.h -- its non'standard and not implemented by very many compilers. Code snippets should not use compiler-specific stuff.

2) delete all those global variables on lines 12 and 13. Just declare them inside the functions that use them. And you will probably have to pass the std* head pointer as a parameter to the functions that use it.

3) a few comments would be nice to explain what those functions do. Your entire program contains not even one comment. Subtract 3 points from your grade for that.

If I were going to grade this I would give it a grade of B. There is a lot of good code there, just needs to be cleaned up.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>mysql_result[3000][2]=msq_row;

If you programmed the rest of that then you should probably know that the above like doesn't work. You should be reading this tutorial. (scroll down to the section Retrieving data from the database)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I found another way to convert to lower case and wanted to see if you thought it would work. I have put it into my code as thus far I haven't found anything else that seems to work.

#include <algorithm>
.... //stuff happening then when user enters flavor,
std::string lowerCase = flavor;
std::transform(lowerCase.begin(), lowerCase.end(),
	lowerCase.begin(), ::tolower);

Why didn't you just convert flavor to lower case instead of creating yet another variable?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not to be repeating myself. . but call of duty came out recently. .

I suppose that means playing a game is more important than doing homework.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>The changes you mentioned have been made except for changing ! == to !=. For some reason, my compiler is not liking !=. I get the error "ISO C++ forbids comparison between pointer & integer". I'm using Cygwin, if that helps.


Your compiler is correct -- I was thinking names was an array of std::string, not characters. use strcmp() instead if( strcmp(names[i], "z") != 0)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

could be re-written like this: Notice you don't need || at all. And that function should only have a return statement at the end of the function, not on every line.

char grade;
    if(score < 60)
        grade = 'F';
    else if(score <= 69)
        grade =  'D';
    else if(score <= 79)
          grade =  'C';
    else if(score <= 89)
        grade =  'B';
    else
        grade = 'A';
   return grade;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't have to store all the lines, just the two lines that you want to compare. Sequentially read the file, counting lines as you go along then save only the two lines you want to compare.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 7 and 8 of the read function: Line 8 is unnecessary because line 7 opens the file when the stream is declared.

line 12: if lastname never contains spaces then use use >> operator instead of getline().

line 13: doesn't make any sense. names is an array, but you are treating it as a simple string. And it is more common to use the != operator rather than ! and == as you have done. if( names[i] != "z") line 15: you are reading in 4 scores, but the array can only hold 3.

line 20: Where is sum initialized to 0? It needs to be done just before the loop starts on line 15.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

c++ has std::string that is declared in <string> header file. google for std::string and you will find links that describe all its methods.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are two problems on each of those lines
1) one, two, three, etc are not defined in that function.

2) char is a data type, but you failed to provide a variable name. For example char something = 1; [edit]What ^^^ said too :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
void swap(int* int1, int* int2)
{
    int temp = *int1;
    *int2 = *int1;
    *int1 = temp;
}


void sort(int int1, int int2, int int3)
{
if( int1 > int2)
{
   swap(&int1, &int2);
}
// now do something similar for the other integers
// Do NOT use else statements.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Deposit $10,000.00 USD in my paypal account and I'll do it for you. Otherwise you will just have to write the program yourself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>The program was initially written in VC++

VC++ is not a computer language. Its an IDE/compiler. So saying you are converting from vc++ to c++ is nonsense.