deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So am I to assume that you completely ignored the replies from your other thread that asks essentially the same question?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm not sure I understand what you're describing, can you be more specific?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You're trying to concatenate to a variable that was never truly given an initial value. Somewhere before the first concatenation, add this:

$topic = '';
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm not able to duplicate this.

Zoom out by one tick (hold down ctrl then hit '-'). It happens in Chrome and Firefox, but not Opera or IE.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster
for i in range(0, n):
    List.append(random.randint(0,1000))
    return (List)

This generates one number, appends that one number, and returns immediately on the first iteration of the loop. You need to move the return statement outside of the loop:

for i in range(0, n):
    List.append(random.randint(0,1000))

return (List)
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

method expects address of the variable/ pointer varible instead of passsing value of the variable while calling the method
but you called this method by passing the value directly so that is the reason you got skipping over the function call

That's a good guess, but you're wrong. The argument evaluates to a pointer, it already represents an address, so no address-of operator is needed in this case. The problem is that reverseString() is all borked up; it shouldn't even compile. Anyway, replace reverseString() with the following and watch the problem go away:

char *reverseString(char *original)
{
    int i, j;

    for (i = 0, j = strlen(original) - 1; i < j; i++, j--) {
        char temp = original[i];
        original[i] = original[j];
        original[j] = temp;
    }

    return original;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i have not defined <stdlib.h> header and included rand() function and it works without this header. How?

If you don't declare a function before using it, the compiler will assume that it's an external function accepting an unknown number of arguments and returning int. If those assumptions hold true, you're good. It's a horrible practice, but it'll work (barring functions with variable arguments like printf()).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In the context of a program's instructions it's a non-issue. You access the logical addresses and the operating system will handle the conversion to physical addresses.

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

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

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

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

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

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

What is it supposed to look like?

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

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

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

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

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

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.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In my mind I was using the concept of a workbook and uploading this container, rather than uploading the individual worksheets.

From an OleDB perspective, an Excel spreadsheet is just a collection of database tables (aka. worksheets) that are named something like "Sheet1$" (default), "Sheet2$", etc... So just like in any database, if it doesn't make sense to query a table, don't query the table. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

when it comes to this kind, should bluetooth or serial (com) ports be used?

Um...it totally depends on what problem you're trying to solve and the hardware involved. For example, I don't imagine a serial port would be an option when communicating between a smartphone and an earpiece.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

is it going to be possible to have a connection if I create a J2ME (netbeans) as client and vb.net (2010) as the server?

Provided they both use a compatible connection method, yes. In some cases you might also need to massage the data to and from what the server expects. This is usually the case when endianness comes into play where it's different on the client than the server.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

so that the code will be something like this i think?

Close. You forgot to close the two strings:

Dim da As New OleDbDataAdapter("Select * from [" & Sheet1_EBU & "]", con)
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

After calling getchar() you need to clear the keyboard buffer of all remaining keys. Unfortunately there is no standard way of doing that.

Well, there's a standard method, but it's situational in that there must be at least one character pending in the stream if you don't want to block for input:

/*
    @description:
        Extracts and discards characters from the stream pointed
        to by in until a newline is found, end-of-file is reached,
        or a stream error is detected.
*/
void clear_line(FILE *in)
{
    if (!feof(in)) {
        int ch;

        do {
            ch = getc(in);
        } while (ch != '\n' && ch != EOF);

        if (feof(in) && !ferror(in)) {
            /*
                Preserve an error state, but remove 
                an end-of-file state if we caused it.
            */
            clearerr(in);
        }
    }
}

The problem is that you have to be sure there are extraneous characters in the stream before calling clear_line() because the following will just pause and wait for input:

int main(void)
{
    clear_line(stdin);
    return 0;
}

So you're replacing one subtle problem with another subtle problem. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think he means that the Workbook contains many Worksheets and he needs to delete the first worksheet before uploading it to the database.

That still doesn't make much sense. Just don't upload the first worksheet.

Unfortunately I don't know anything about using Excel in C# so beyond my interpretation I can't offer anything else ^^

He's accessing Excel through an OleDB connection, so aside from a few sticking points like the worksheet name, it's just straight ADO.NET. I like to use this method as well for when installing Office on a machine is prohibitive (the "official" Excel interop requires office to be installed...), even though it's not as convenient for more advanced tasks.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm not sure I understand the requirement. You want to clear the Excel workbook before uploading it to the database? That sounds like a no-op, since the upload on an empty file will do nothing. Perhaps you mean clear the file after uploading? But if that's the case, why not just delete the file?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In the following program

You forgot to include the following program.

What do the mean by that?

It means what it says. C++ doesn't stop you from walking off the end of an array:

int a[4];

// Don't do this
for (int i = 0; i < 100; i++) {
    a[i] = i;
}

This invokes what the standard calls undefined behavior, because it can corrupt adjacent memory or cause access violations if you try to access memory outside of your address space or memory that's protected in some way.

I thought arrays were not changable anyway

The size of an array is not changeable. The contents can be changed provided the array isn't specified as being read-only through the const keyword.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Those folder icons tell you the read status of the forum. When you click on the folder, it makes the forum as read, it's not supposed to navigate you to that forum. If you want to go to the forum, click on the name of it instead of the folder beside it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but i believe in case of without copy constructor it must have printed same memory address due shallow copy

That's not the case because you aren't printing the address contained by the pointer, you're printing the address of the object that owns the pointer. Change your show() method to this so that you can see the difference in addresses contained by the pointer:

void show() const
{
    cout << "integer=" << (void*)m_p << endl;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So, I'm suppose to make a program following these guidelines.

Good luck with that.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So there's now way to look inside std and cout and width for myself?

You can if you want, but unless you're pretty advanced in your C++ knowledge, it'll look like gibberish.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can you be any more vague?

uurcnyldrm commented: Being administrator does not give you the right of making fun of people. I am new and the question might be askedin a wrong way but the people who understood what I meant just helped me. I don't know what kind of mentality brings you there. You are probab +0
Begginnerdev commented: Only if the question was, "Help?" +8
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Test it out and see:

#include <iostream>

using namespace std;

int main()
{
    cout << "'";
    cout << "foo";
    cout << "'\n";

    cout << "'";
    cout.width(10);
    cout << "bar";
    cout << "'\n";

    cout << "'";
    cout.width(10);
    cout.setf(ios::left);
    cout << "baz";
    cout << "'\n";
}

As for where to figure these things out, a combination of a good tutorial book and a good reference book should cover most of the bases. From there it's experimentation and self study.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I also reported a bug that I can't upload screenshots from my PC because it says "it exceeds max width * height"

How big was the screenshot?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What is the maximum allowable size for uploading files? Is this a per attachment limit or is it a per post limit?

1MB, per attachment.

When the error message (finally) comes up, perhaps it could specify what the maximum size is.

Noted. I'll have to see what's actually included in the error messages.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

a = here*;

This isn't valid syntax.

and in the function I check if here is NULL or not

You're not checking if here is NULL, you're checking if here->key is NULL. here->key is a char, so the test is nonsensical given that one of the operands is not a pointer. If here is NULL then trying to access key will result in an access violation. You want to do this:

if (here == NULL)
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The file sizes were 1,351,013 bytes and 304,896 bytes.

1MB is the size limit for attachments, so the first one is too big.

They were chm files.

And chm isn't a supported upload type. Try zipping those files and uploading the archive. It looks like the problem with the files not uploading in IE was simple lack of support, though I'm a little concerned that the errors weren't showing up. We definitely trap attachment errors and list them on the page.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

And what about the files themselves? Specifically the type and size.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are you getting this problem in the quick reply box or on edit? What version of Firefox? What OS and version of the OS? Do you have any notable add-ons installed? If you view page source are the input tags present and just not rendered, or are they missing entirely?

It's broken again. I've completely cleared the cache and still there are no text entry/browse buttons.

It's not really broken again because it was never really fixed. I been unable to reproduce this error for nearly a year, and fixing something I can't reproduce is somewhat difficult.

I tried attaching the files via IE. While the text fields and buttons rendered, and I was able to browse and select the two files, neither of the files actually got attached.

Can you link to the post you were attaching files to? Also, what type and size of file are we talking about?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In lines 11 and 15 you're assigning to $count, not comparing it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

GIMP is the open source equivalent to Photoshop, but don't expect it to be as user friendly. I'm not familiar with the latest HTML packages. try searching Google. I use NetBeans if you're interested, though it's more of an IDE for PHP than a website designer like Dreamweaver.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There's a space at the end of the format string in scanf(), remove it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

it keep showing me only 1 movie count even there are more!!

Debug the code and figure out what's wrong then. I don't have your file to test with, so I can only go on what you've provided in this thread.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Anyone know how to do it that way?

Unless you feel like dropping down to inline assembly, the best (only) solution is to verify that the operation won't overflow before you perform it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes, I opened on in an other file, and an otehr class. Do I need to open one in this class aswell?

I'd keep connections local to the class that uses them, but that's because I'm stupid and need the extra help. ;) Provided you open the connection before making calls to mysql_query(), it should be okay, but you do need to consider order of operations since it's not super explicit.

Your query is simple, but it still couldn't hurt to echo the final string that gets passed to mysql_query() and run it manually from MySQL just to be sure it works the way you think it works.

Also, include error checking with mysql_error() for more details about the problem:

$result = mysql_query($query);

if (!$result) {
    die('Error: ' . mysql_error());
}

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

Your query failed for some reason. I notice you didn't provide a connection as the second argument to mysql_query(), have you opened a connection to the database already?