Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. Skatanic

    Backslash interpreted incorrectly

    I don't know why the ALT-F8 sets it up like that but in order for the \ to work like that you need to make sure everything on the next line has NO preceding characters. Push all that to the front of the next line and it should work fine. However, I will say that the \ character like that is...
  2. Skatanic

    bitwise logic operations

    You don't put in the 0x part. Just type in the 4 digit number in hex. -Skatanic
  3. Skatanic

    Simple file IO

    You can use getline and use the delimeter character n times. Then the nth time you will have what you are looking for. Just a very basic solution. Could be something better. -Skatanic
  4. Skatanic

    Linking Errors Using Template Classes

    I honestly think that is an issue with MSVC++. I just ran into that problem quite recently. There are two workarounds that worked for me. One was to put all the function definitions in the header file (whether inline or after the definition). Another was to include the .cpp file instead of the...
  5. Skatanic

    c++ string manipulation

    Here is some code that will work. It is not as simple as calling one function. std::string str = "first middle last"; unsigned int first; unsinged int last; first = str.find(' '); last = str.rfind(' '); std::copy(str.begin()+first+1, str.begin()+last...
  6. Skatanic

    change last element of a queue

    There shouldn't be. Period. You SHOULDN'T be able to do anything to anything in the queue except for pushing to the back and popping from the front (OK and looking at the front). ... ... HOWEVER... For an STL queue, there is a function called back() that will return either a const reference to...
  7. Skatanic

    enum or const int: which is better?

    Actually #define macros and constants are considered obsolete in C++. It allows for a lot of implicit casting that you might not know is happening. It is better to use the const constants because you specify an exact type and that is actually stored in memory. All #define does is cut and paste...
  8. Skatanic

    Random float generation

    Let me explain with this example: float some_float; int some_int1, some_int2; some_float = some_int1 / some_int2; First, the compiler has to compute the division. Since they are both integers it does this by integer division. Then the compiler notices it needs to cast that quotient to a float...
  9. Skatanic

    Random float generation

    rand() returns an int so you need to cast them in order to get the float. Try: check = (float) rand() / (float) rand(); -Skatanic
  10. Skatanic

    password creation

    Just a side note as well... The '\r' character works for Windows because that is what is sent when you press return. For other operating systems I don't know if it sends '\r' or maybe '\n'. Try both out. -Skatanic
  11. Skatanic

    password creation

    Hey... this should work. It looks kinda sloppy, but it will print a '*' for each character typed. You will want to add code to make sure they do not type in more characters than are allowed, etc. But keep this basic structure to echo '*' characters. int main() { char c; char pwbuff[32]; int...
  12. Skatanic

    enum or const int: which is better?

    Enumerations are used for when you want to declare a variable that will have different states. They are used such that you can limit a certain variable to those limited values. So if you were using a variable that could ONLY have the values 1, 2, or 3 and you wanted to check which it had, then...
  13. Skatanic

    Convert double to string

    Here is the prototype for it. char *_gcvt( double value, int digits, char *buffer ); Shouldn't be too hard to figure out. Just make sure to include <stdlib.h>. -Skatanic
  14. Skatanic

    Simple Array Question

    It is impossible to find out the size of a dynamically allocated array (using new or malloc). sizeof can only find out the size of static arrays like buffer[54]. If it was dynamically allocated there is no way to find out. Your best bet is to add an argument to the function (just an int) to keep...
  15. Skatanic

    Multidimensional Array Problem

    Could you post the code that you are using to output it to the file so we can see if the problem might be there?
  16. Skatanic

    Is deque thread-safe?

    No.. nevermind... That can't work like that. I just got it to crash right after I posted the question. (I was even trying to stop the post from posting it was that soon ;-) ) There is the case when there is just one element in the queue. Pushing onto the queue has to edit the element for that...
  17. Skatanic

    Is deque thread-safe?

    I was wondering if anyone knew if it was possible, in ALL possible situations, to push into a queue made from a deque and pop from the queue from different threads without using some form of mutal exclusion? It seems like the push does not corrupt the other elements, but I don't know if that...
  18. Skatanic

    Multidimensional Array Problem

    You can dynamically allocate the array: void createIntArray(int inRows, int inColumns){ int **temp; temp = new int*[inRows]; for (int j=0; j < inRows; j++) { temp[j] = new int[inColumns]; } } The problem is that normaly arrays need constants as their parameters...
  19. Skatanic

    volatile declaration problems

    I am using threads to update an STL multimap holding my data. Since they will be concurrent I am trying to declare the multimap as volatile. However this produces a compiler error on the line when I call the insert function for the multimap. When I remove that keyword, it compiles fine. My...
  20. Skatanic

    How to hex2ascii???

    That code should work with the hex numbers. strtol recognizes characters 0-9 and A-F when 16 is passed as the base.

Part and Inventory Search

Back
Top