deceptikon 1,790 Code Sniper Team Colleague Featured Poster

ah and al are both under the ax registry right? well is there a significant difference between ah an al?

AH and AL are the upper and lower bytes of the AX register. Much like AX is the lower 16 bits of EAX and EAX is the lower 32 bits of RAX. They're general registers, but some instructions expect operands in a specific register or part of a register or write to a specific register or part of a register.

For example, let's take this block:

mov ah,01h  ;ask user
int 21h
add al,20h  ;converts uppercase to lowercase
mov bl,al

int 21h (if you read the documentation I linked earlier) states that an operand in AH of 01h will cause a character to be read from standard input, and the character that's read will be stored in AL. BL is the more permanent storage for the character as other work is performed using AX prior to printing that character.

And before you ask, yes, it could also be done like this:

mov ah, 01h
int 21h
mov bl, al
add bl, 20h

There's not really any reason to add before moving or move before adding. There may be a performance reason I'm not familiar with, but in this case I doubt it given that you're working with two general registers of the same size.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Could you be more specific about the OSes in question? I suspect that it's an endianness issue. I'm not aware of HP-UX support on little endian architectures, but Linux supports both big and little endian depending on the hardware. If you're running Linux on something like an x86 then I'm not surprised you're getting reversed results from the two platforms.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Let's start with int 21h, because it seems like magic if you're not familiar with the multipurpose functionality. It behaves differently depending on the value of the AX register.

mov is just shuffling data around, I'm not sure I need to explain it unless you have a specific question.

Line 11 is where the real work of the conversion is done:

add al,20h  ;converts uppercase to lowercase

It's brittle in that the program doesn't check to make sure the character has a lower case equivalent before doing the conversion, but in the ASCII character set upper and lower case letter blocks are 32 characters apart, so if you add 32 (which is 20h in hexadecimal) to an upper case character you'll get the corresponding lower case character, and if you subtract 32 from that, you'll get the original upper case character.

For example, 'A' has a value of 65 and 'a' a value of 97. 65 + 32 = 97 and 97 - 32 = 65. Easy peasy.

int 20h terminates the program.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

how exactly I write that there is 2 parameters should be entered by the member? or just click the search button?

I'd break the logic down like this:

If NOT empty(course_id)
    search_exact(course_id)
Else If NOT empty(course_name)
    search_fuzzy(course_name)
Else
    list_all()

If there's a course ID, it's safe to assume that the ID is unique and you can find either an exact match or the course doesn't exist. Otherwise, if there's a course name you could potentially find multiple courses with matching or similar names which may result in no matches. Finally, if you have neither an ID nor a name, list all active courses.

To be more generic: unique keys can short circuit the algorithm because a unique key will give you an exact match. Non-unique keys could return multiple results and come next. Lastly, no valid input is either an error or matches everything, depending on your needs.

Please guid me thru what keywords should be used instead of what I used above in my attempt.

Pseudocode has no rules. Unless you've been given a specific set of keywords that are allowed, just do what makes sense to you and is logically consistent.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

When a simple-escape-sequence like '\n' is evaluated, what would be the result?

It's evaluated as the platform-dependent character for a newline. For example, on Linux '\n' will be evaluated as LF (ASCII 10) while on Windows it'll be evaluated as CRLF (ASCII 13 + ASCII 10). But it's totally irrelevant unless you're bypassing the standard I/O framework because those translations will be done under the hood. Your program will never see anything except '\n'.

How I can show ASCII 10 as a character?

Just print the value 10 in character context:

printf("ASCII 10: '%c'\n", 10);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I have yet to effectively use these expressions.

It's fairly straightforward when compared with an if..else statement. This:

x = (condition) ? foo : bar;

Becomes this:

if (condition) {
    x = foo;
}
else {
    x = bar;
}

IF you don't need to make an assignment and are instead just performing an action with a side effect, this:

(condition) ? someAction() : someOtherAction();

Becomes this:

if (condition) {
    someAction();
}
else {
    someOtherAction();
}

That's really all the ternary operator does. A benefit is that it can be used in an enclosing expression where the if..else statement cannot.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Even if what you want was trivial enough to post in a reply (it's not, by the way), we don't give homework help without proof of effort. Please read our rules, definitely read this, and try again.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It really depends somewhat on how you declare your pointer. For example, a static or global pointer will be default initialized to null. A local pointer will contain random garbage if not explicitly initialized, just like any other local variable.

Best practice is to initialize your variables in all cases to avoid having to remember and apply the different rules to the given situation.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I am still kind of confused.

Consider speaking with your teacher instead of looking for help online. I could clear up your confusion on this topic easily with a little bit of hand waving and a whiteboard, but it's tedious to no end using forum posts.

Can you o into more details please

It really boils down to this: The address of the variable a is 0xFF2a. If the size of the variable a is 4 bytes then the address of the next variable (b in this case) is 0xFF2a + 4, or 0xFF2e. Repeat the process to get the address of every variable in the program.

Once you have the address of every variable, learn how pointers work and then use paper and pencil to write down the result of each executable statement in the program. If you know how pointers work, it's trivial. If you don't, it's impossible.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The logical OR (||) and bitwise OR (|) are also subtly different. Sometimes you'll get the same result and sometimes you'll be surprised, so I'd recommend not using the bitwise OR in situations where you clearly want a logical OR. This is one of those situations, so your test should be:

if ((a[0] == 'y') || (a[0] == 'Y'))
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The exercise seems to be one for paper and pencil. The first variable (a) has a hypothetical address of 0xFF2a. You're to determine the addresses of the other variables, and also work out the values of the pointers and variables after all of the listed statements are "executed". For example, after line 7 is executed (and assuming that both float and int are 4 bytes) you'd have this:

a (0xFF2a): 32.5
q (0xFF4a): 0xFF2a
    *q (0xFF2a): 32.5

I got the address of 0xFF4a by adding 20 bytes (5 variables at 4 bytes each) to the base address. You can follow a similar process for each of the other variables to get its address.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The annoying use case is this:

for (vector<int>::size_type i = 0; i < v.size(); i++) {
    cout << v[i] << ' ';

    if (i == v.size() - 1) {
        cout << endl;
    }
}

C++11 offers the auto keyword for initializer type deduction so that we can avoid verbose and ugly types like vector<int>::size_type. However, the naive attempt doesn't work:

for (auto i = 0; i < v.size(); i++) {
    cout << v[i] << ' ';

    if (i == v.size() - 1) {
        cout << endl;
    }
}

The reason it doesn't work is because 0 doesn't match the type of v.size(). Worse, v.size() is an unsigned type while the literal 0 is a signed integer. At most there will be a warning, but that's still annoying, so I set out to come up with a better option that's consistent across the board and has a more conventional syntax.

Option 1: decltype

C++11 also offers the decltype keyword for deducing the type of an expression or entity. In this case we can deduce the type of v.size() and use that for the type of i. Everything works nicely with perfect type matching and no warnings, but it's kind of ugly syntax-wise:

for (decltype(v.size()) i = 0; i < v.size(); i++) {
    cout << v[i] << ' ';

    if (i == v.size() - 1) {
        cout << endl;
    }
}
Option 2: Iterator arithmetic

An option that exists prior to C++11 is by using iterator …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Quote your string in the SQL statement:

string OrdersLine50CustomerSQL = "SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, accAccRef_FKID from cashOrders WHERE cashOrders.accAccRef_FKID = '" + CustomerID.ToString() + "'";
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

file_to_check.close();

That's not necessary. If the file is open, the destructor for ifstream will close it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So in the following code, is message an array because it doesn't really look like one?

Yes. The string literal is actually stored as and has a type of array to const char. When used in value context it evaluates to a pointer to the first element, which is why you can assign it to a pointer. It's also a holdover from C that you can assign a pointer to const char (in this context) to a pointer to char, which would normally be illegal without a cast.

To be strictly correct, any pointers to a string literal should have a type of const char* because string literals are technically supposed to be read-only.

I thought that the number in the [] of a char array would dictate how many characters are in the array but in this case it's how many strings all together. What have I missed here.

You're storing an array of pointers, the size of the array dictates how many pointers the array can hold, which in this case is 4. It helps to think of int instead of the pointer to char aspect is confusing you:

int members[4] = {1, 2, 3, 4};

The fact that the array holds pointers to char, which can be the first element of a string is irrelevant to how the array works. You need to understand the pointer to char as a string and array concepts separately, then combine them without mixing them …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Saying Columbus discovered America is like saying Isaac Newton discovered gravity.

discover (v): to see, get knowledge of, learn of, find, or find out; gain sight or knowledge of (something previously unseen or unknown). I fail to see how these people didn't make discoveries for their respective country or region. Just because something exists prior to being found doesn't mean it wasn't discovered. Likewise, just because people lived in the Americas before Europeans found it doesn't mean the Europeans didn't discover the Americas relative to the understanding of the world they previously had.

I'm going to nitpick here.

You could also nitpick the choice of Columbus as the discoverer of America for Europe given that Norse explorers landed on North American soil long before Columbus.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Have you considered running Fedora in a VM? If all you need is a *nix system for the shell programming class, that strikes me as the better option than completely wiping your laptop and installing an OS that you may not use for longer than a few months.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm assuming that clever replacements for string.Split() are off the table too. Try looping over the characters in the string and print a newline when you reach whitespace:

foreach (char c in s)
{
    if (!char.IsWhiteSpace(c))
    {
        Console.Write(c);
    }
    else
    {
        Console.WriteLine();
    }
}

That's the simplest approach, but it makes some pretty big assumptions such as there won't ever be multiple adjacent whitespace characters. If that's the case, you need to take that into account and only print one newline for each span of whitespace. But the above should get you started.

tux4life commented: Cookie time :) +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Look at the definition of _real4_t and usage (in the form of _real8_t, but they're equivalent) in the following code:

_real4_t
Sample usage

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It needs to print out signBit, expBit, and fracBits.

What, pray tell, are expBit and fracBits supposed to represent for an integer?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Please read our rules concerning homework problems. You've failed to provide sufficient proof of effort.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What is it supposed to look like?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

By a three dimensional array, it seems like you mean a two dimensional array where the second dimension is an array of three items:

var peeps = [
    ["Bob","Jones", 36], 
    ["James","Brown", 29], 
    ["Lloyd", "Mals", 45]
];

If nothing else this is better than parallel arrays because related entities are kept together instead of in separate objects.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why do you keep starting new threads for the same program? Please stick to one thread unless the questions are wildly different.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So the obvious solution is to create a tile with this information on it

Yes.

but I would just like the window to float over the tiles in the "header" of the page, because a tile will move off of the screen and out of view.

If I understand correctly, you're basically trying to take over the Metro view and force your tile to be visible regardless of which app is active. Until and unless Microsoft opens up their charms bar to allow custom charms, and unless you're okay with the caveat that your app is made visible by splitting the app view, you're asking for something that's not possible (as I understand Windows 8 currently).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Where are you storing the information and what are you planning on doing with it? How you store it will change depending on what your needs are in terms of how the data is used.

Basically that; Im thinking about a 3 demensional array. Would this be correct?

Unless you mean something different by "dimension" than general computer science, I'd say a 3D array is probably a very poor choice, regardless of your answer to the questions above.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Falling off the end of a function doesn't return anything meaningful. What you want is to return the result of the recursion (see line 13):

public static bool FindTarget(int target, int[] arr, int index)
{
    if (index >= arr.Length-1)
    {
        return false;
    }

    if (arr[index] == target)
    {
        return true;
    }

    return FindTarget(target, arr, index + 1);
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My program runs but I feel like it is missing something else.

Yes, you're missing the subroutine. Declaring a function is only half of process, you also need to define the function and tell it how it works:

#include <iostream>

using namespace std;

// Declaration: Tells the compiler how a function is called
int multiply(int x, int y);

int main()
{
    // You can compile a call to the function with only a declaration,
    // but a definition is required for the code to run.
    std::cout << multiply(5, 2) << '\n';
}

// Definition: Tells the compiler what a function does
int multiply(int x, int y)
{
    return x * y;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

1) Leave the explanation of what a function does outside the function, and the comments about how it is done inside the function, near the code that does it.

I'd go even further (since I'm a sparse commenter) and say that comments should be limited to the following (examples taken from here, and recognizing that there's some redundancy with your recommendations):

  • Do comment why the code is there and why it works. This can be a business-level explanation of the problem that's being solved or a summary of the following block of code that saves the reader the trouble of deciphering what's happening and making an assumption about the intended purpose. Two examples:

    /* Strip leading whitespace */
    while (isspace(*it))
        ++it;
    
    /* Check for an integer part sign */
    if (*it == '-' || *it == '+')
        sign = (*it++ == '-');
    

    Notice how the code is reasonably clear without the comments, but the comments really nail down what the author was doing with each block.

  • Do comment how the code is intended to be used. This is in reference to things like Doxygen comments that are useful in generating documentation as well as providing code-level documentation.

  • Do include things that are going through your mind as you write the code. The reader won't necessarily be as intimate as you are with the problem and the solution, so there may be confusion if you're not expressing it. Two examples of comments that highlight what …

tux4life commented: Redundancy doesn't hurt in the case of good advice ;) +13
bguild commented: Vertical space is a valuable resource +6
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

so how connectivity of oracle is possible with c++?

Start by googling for an oracle database library that supports your old as dirt compiler. Then read the documentation and tutorials for that library, and you'll be in a much better position to do your project.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I would like to write a little program that is a little floating window, that can be viewed on both the "Metro" screen and on the desktop, is this possible?

As I understand, Metro doesn't support any kind of windowing system that would give you something "floating", it's all or nothing with whatever you can manage in webpage style. You'd also need to write two separate programs, one for Metro and one for the desktop, because they don't interoperate using the same executable.

I would like to be able to have an option screen, where I can turn its visibility off and on in either screen, but I'm not sure whether it's achievable in the first place?

It would be more helpful if you described the point of this program as opposed to any specific features you want.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yup, but that implies I have to convert it from a date format to a string then convert it back.

Nope, you just need to convert it to a string since you already have a valid DateTime object:

string formattedDate = dateOfBirthUpdate.DateOfBirth.ToString("yyyy-MM-dd");    
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

the actual excel file...

Okay, so within the Excel file are you trying to remove a single worksheet or does the file only consist of one worksheet? The ideal situation would be if you could just delete the file since that's the simplest. If you really need more control over the spreadsheet than insert, update, and select, you'll have to move to a more specialized library than ADO.NET such as the Microsoft Excel interop or any number of third party libraries that support Excel automation (NPOI, for example).

Why you'd want to delete from the database I don't know, seems kind of pointless...

I can imagine a "latest report" table where the previous report would need to be removed before inserting the new one. It's not completely unreasonable, but in that case unless there are static rows that can't be removed a simple truncate command would suffice:

public void ClearLatest(SqlConnection connection)
{
    new SqlCommand("truncate table latest_report", connection).ExecuteNonQuery();
}

Foreign keys would throw a wrench into a simple truncation, but then I'd question why such a transient table has foreign keys in the first place.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In the south it feels like spring time, it's January, I like the cold, and your name is chilly. I ban you for reminding me that I haven't properly had my winter yet this year.

Taking bets on how many people will check to see if chilly is actually banned after reading this. ;D

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The == operator is used for comparison, it's different from the = operator which is used for assignment. Also, it may seem confusing at first, but you don't end the line of an if statement with a semicolon. It's legal, but doesn't do what you want.

Simple statements do end in a semicolon, and the prefix ++ is technically a little more correct than the postfix ++ because it's theoretically faster and more clear what you want in this case.

Compare and contrast:

if (num % 2 ==0)
    ++pcount;
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

-payroll system, inventory system, accounting system

Inventory is easy, accounting and payroll are quite a bit harder.

I want it to be like a web database

For payroll and accounting? No offense, but that's a really bad idea. An intranet portal is fine, but making it web accessible would be the height of stupidity, in my opinion.

Please give me professional idea, my idea is newbie ^_^

If this is for professional use, I'd highly recommend buying an existing package for each use. They'll be more mature and far less likely to fuck things up than a custom solution.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I bet Southerners get really cheesed off being referred to as 'Yanks' too.

Not especially, at least in my case. Then again, I tend to be apathetic about such things in general. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Post an example of $comment itself. As an example, this works:

<?php

$comment = "test\r\n\r\n\r\nfoo";
$comment = preg_replace("/(\r\n)+/", "\r\n", $comment);

echo $comment;

?>
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My bad, I should have used double quoted strings:

$comment = preg_replace("/(\r\n)+/", "\r\n", $comment);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

SetParent() is evil (at least the way most people try to use it). It's throwback support for a Windows 3.1 hack, and the behavior is especially wacky in WinForms. Strongly not recommended, which is why I didn't even mention it. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I've needed to write sample code using conio.h over the years, but my compilers don't support all of it (most notable being clrscr() and gotoxy()). So I wrote a conio simulator class to help me. Not all of the conio.h functions are present, such as cgets() and cscanf(), because I haven't needed them. But the design is such that they can easily be added.

It's based around an abstract IConio class that can be inherited from for specific implementations. The conio.h library is very platform specific, and I've included a Win32 implementation as I work primarily with Windows systems. POSIX implementations aren't especially difficult, but I don't have the confidence in writing something I'd want to show off. ;)

Here's an example program based on one of the samples I wrote recently:

#include <iostream>
#include <string>
#include <Windows.h>
#include "coniolib_win32.h"

namespace {
    const console::IConio& conio = console::Win32Conio();

    enum {
        KEY_ENTER = 13,
        KEY_ESC   = 27,
        KEY_UP    = 256 + 72,
        KEY_DOWN  = 256 + 80,
        KEY_LEFT  = 256 + 75,
        KEY_RIGHT = 256 + 77
    };

    enum {
        HILITE_SELECTED   = 433,
        HILITE_UNSELECTED = 23
    };

    int get_key(void)
    {
        int ch = conio.getch();

        if (ch == 0 || ch == 224) {
            ch = 256 + conio.getch();
        }

        return ch;
    }
}

int menu(int selected_row = 1)
{
    const int size = 3;
    const std::string rows[size] = {
        "1) Option 1",
        "2) Option 2",
        "3) Option 3"
    };

    conio.clrscr();

    if (selected_row < 1) {
        selected_row = 1;
    }

    if (selected_row …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Try using a regular expression to replace multiple instances of CRLF and newline with a single instance. You probably also want to consider including break tags:

// Squeeze break tags
$comment = preg_replace('/(<br\s*\/>)+/', '<br />', $comment);

// Squeeze CRLF
$comment = preg_replace('/(\r\n)+/', '\r\n', $comment);

// Squeeze NL
$comment = preg_replace('/(\n)+/', '\n', $comment);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

And this is why i am not being able to decide, what would attract audience the most..

Honestly, were I visiting a university and attending a presentation, I'd be more impressed with a solid project/presentation than an attractive or exciting project/presentation. The biggest problem I've seen with folks coming into the field from college is an almost universal inability to get things done. On the job training and experience fixes the problem quickly, but if you can show these CEOs that you can get things done, they'll be impressed regardless of the actual technical content.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but i m not able to think of any such thing..

That's sad. So you don't have any interests? You don't understand your audience well enough to figure out what might interest them? You don't have any teachers or peers who have any interests or ideas for anything at all?

No disrespect intended, but from your posts so far you strike me as astonishingly lazy. If you're unwilling to put in the effort in merely thinking of a project idea, the chances of actually finishing the project are vanishingly small.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is this a separate application or just another form in your program? If it's the latter then you can do what you want with an MDI setup. If it's the former then I'm not going to say you can't do it, but the concept is like saying "I want to subvert the design of Windows and do something completely different using the system's API", which is likely to be either not possible or wholely impractical.

I'll welcome any corrections, because that would be a nifty feature, but it strikes me as the wrong approach to whatever problem you have.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Or should I really be using vectors?

Given that you seem to be having quite a bit of trouble with arrays and pointers, I'm going to go with yes, you should be using vectors.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are you wanting to clear data from the database or the actual Excel file?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Actually, Daniweb supports both changing of names (it's a one time change per account) and deleting of accounts. Either of those can be done from here.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I just want to send a word from my mobile as signal to my pc to do other task...

You have a number of options in this case, assuming a smartphone. The most general would be simple HTTP where the PC hosts a web service and the mobile connects to it. You could probably also use SMS, but I'm not very familiar with the protocol. If you want to communicate wired instead of wirelessly, how to go about it kind of depends on what the mobile supports in terms of connections and protocols through those connections.