•

Check out our Community Blogs

# dargueta

Member Since 07 Oct 2007
Offline Last Active May 18 2019 05:29 PM

### #680815I give up.

Posted by on 25 October 2015 - 04:49 PM

Sad to see you go, WP. You've been an integral part of the CC community, and I think I speak for everyone here that we've learned a lot from you. Happy Coding!

PS: I think this makes me the last moderator left...

• 1

### #680514This site has turned into a spam fest

Posted by on 20 September 2015 - 09:22 PM

I have yet to see him around aside from his initial announcement about the takeover.

• 2

### #677253I hate being sick

Posted by on 03 January 2015 - 11:17 PM

Healthcare can get expensive, so I avoid going to the doctor for minor things like a cough.

• 1

### #677184I hate being sick

Posted by on 31 December 2014 - 02:43 PM

No one missed you.

• 1

### #671947How to clear the console screen with ANSI (Any Language)

Posted by on 06 June 2014 - 07:44 AM

FYI

You should clear attributes before your program exits using \033[0m or else those attributes will still be applied after your program is done.

This will not work on versions of Windows beyond 98 without manually enabling ANSI.SYS. Otherwise you'll actually see all the escape codes.

You can find out how to do that here:
http://support.microsoft.com/kb/101875
• 1

### #663698Conficker??? real or fake

Posted by on 07 September 2013 - 07:41 PM

Please don't post on threads more than, say, about a month old unless it's a tutorial. This over four years old.

• 1

### #651082[cryptography / python] Caesar Shift encryption

Posted by on 28 January 2013 - 05:05 PM

That's the modulus operator, which simply divides the left side by the right and returns the remainder. For example:

2 doesn't divide evenly into 5...
5 % 2 = 1
5 / 2 = 2.5

...but it divides 6 just fine.
6 % 2 = 0
6 / 2 = 3

You don't always get 1 or 0 though.
100 % 26 = 22
100 / 26 = 3.846...
• 1

### #643605.h vs .cpp - When to use them?

Posted by on 04 November 2012 - 06:03 PM

Here's my two cents:

.h files tell you what you can use, .cpp files tell the compiler how to implement those things that the .h files say you can do. Oftentimes when third parties provide libraries to programmers, they give you a binary library and .h files, but not the original source code in the .cpp files. This way, they can hide how their libraries are actually coded, but still let you use them.

Make sense?
• 1

### #643513Comparing Characters in Strings

Posted by on 03 November 2012 - 05:46 PM

Well, standard string library isn't as good as String library in Qt (QString) or C#, or java strings. There is no ( that I know ) method in standard string library to lower or upper case characters.As you see I am comparing ASCII values(decimal ones) of each character in passed string.
then if value is out of lower's character range I'm incrementing it's ASCII value.
Go on check it out and try to make own toUpper function.

Um...
```#include <ctype.h> // If you're using C
#include <cctype> // If you're using C++

void strlower(char *s)
{
for( ; *s != '\0'; ++s )
*s = tolower(*s);
}
```

The great thing is, if *s isn't a letter or other character that doesn't have a lowercase version, nothing will be changed, so you don't have to do an if statement.

As for your original question, you can use stricmp in the standard C library. Include string.h.

It's a good idea to do as little modification of the inputs as possible; in fact, you shouldn't unless it's absolutely necessary. What I recommend is this:

```bool compare_nocase(const char *a, const char *<img src='http://img.codecall.net/public/style_emoticons/default/cool.png' class='bbc_emoticon' alt='B)' />
{
while( (*a != '\0') && (*b != '\0') )
{
if( tolower(*a) != tolower(*<img src='http://img.codecall.net/public/style_emoticons/default/cool.png' class='bbc_emoticon' alt='B)' /> )
return false;

++a;
++b;
}

return *a == *b;
}
```

• 1

### #643163[SOLVED]Why are library functions erasing the contents of registers?

Posted by on 30 October 2012 - 04:23 PM

No, in fact if you look at the documentation here, it says that scanf() returns the number of fields stored to. A return value of 0 means that nothing was read.
• 1

### #643084[SOLVED]Question about getting user input(IA32)

Posted by on 29 October 2012 - 08:14 PM

scanf() can't store to a register. You need to create a variable in memory and push the address of that variable to the stack, then load that variable into ECX.
• 1

### #642474[SOLVED] Sort two dimensional array

Posted by on 20 October 2012 - 05:38 PM

You can use the bubble sort with an index like this:

my_array[i / 3][i % 3]

This will make accessing it like a linear array.
• 1

### #641809HW- Ruby 2d array

Posted by on 13 October 2012 - 11:47 AM

2D arrays
http://stackoverflow...objects-in-ruby
http://www.ruby-forum.com/topic/141223

self is a pointer to the current object, used in class definitions to call a member function of that class instead of a global function by that same name, or access a member variable instead of creating/reading from/writing to a local variable by that name.

super() invokes a specific class method implemented by that particular class' parent class. For example, if class A has a function named foo(), class B inherits from A and overrides foo(), then class B can use super() to invoke A.foo() instead of B.foo() as would be the default.
• 1

### #641152Hello Sir/Ma'am, About Intrusion Detection System

Posted by on 08 October 2012 - 09:46 AM

Considering this is a low-level utility that must operate in real time, you'll probably have to use C/C++.
• 2

### #641150C++ output without moving the console cursor

Posted by on 08 October 2012 - 09:42 AM

Have you tried using WriteConsoleOutputCharacter() instead of printf()? I'm pretty sure that doesn't move the cursor. However, it won't accept format specifiers, so you'll have to use sprintf() to format your output and then pass that to WriteConsoleOutputCharacter(). Since you're using C++, I would recommend using a string buffer instead, like this:

```#include <windows.h>
#include <sstream>

std::ostringstream outbuf;
COORD cWhere;
DWORD dwCharsWritten; // <-- this might not be necessary

outbuf << myvar << " blah blah " << -193 << endl;

cWhere.x = 5;
cWhere.y = 9;

// You might be able to pass in NULL if you don't want to keep track of the
// number of characters written. Some functions allow you to do this, others