deceptikon 1,790 Code Sniper Team Colleague Featured Poster

insead of talking, Dani should sit and rewrite it

That's not how professional software development works. First the requested feature is discussed for viability:

  • Is this feature necessary?
  • Is there an acceptable workaround?
  • Does the feature fit within the intended design?

If it's determined that the feature is viable, then a followup discussion is had about its practicality:

  • Do a critical mass of users want the feature?
  • Is the benefit of the feature worth the cost of implementing and maintaining it?

If the feature is deemed practical, a proof of concept is created to work out the kinks. Finally, if there are no significant problems from the proof of concept, the feature is implemented into the product and goes through the release cycle.

Let's talk about quoting, since that seems to be your biggest beef. Thus far I've seen only one feature request, and that feature is to support cross-page quoting. I started the discussion on viability with you and it didn't seem to go anywhere. Other problems with quoting were too vague to even begin any kind of discussion.

You seem to be expecting magic. We need lots of information in a feature request to answer the above questions, and I have yet to see that information reported in any meaningful way.

when you want to be respected, just respect others

Indeed. Odd how you haven't been following that advice. In fact, you stated quite clearly that you will not respect the developers …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Tried different things myself, but as I'm a still a learner and could find nothing useful on the web, I'm a bit stuck.

It may help your search to know that what you're looking for is called return type covariance. To simplify your search drastically, C# doesn't support it even in the latest version. ;)

There's likely a workaround though, if you specify exactly what you're trying to accomplish rather than simply paraphrasing it for the sake of simplicity.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Because Microsoft hasn't ever bent over backward to support ancient software/drivers, or shoddy coding practices for the sole purpose of avoiding breakage as Windows and hardware evolves. :rolleyes:

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's not the fault of Microsoft.

But why think about it when you can just blame Microsoft for everything bad that happens in computing? ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Um...what?

Moschops commented: I can't disagree with this assessment. +13
rubberman commented: Did you mean baby sitters? :-) +13
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If the sample of the file you presented is accurate, then it's not a binary file, it's a variant of CSV. fread with that structure won't work since the file has to be parsed as a comma separated format. For it to work, the file would need to be created with fwrite using an object of the structure, and opening the file certainly won't give you a comma separated format.

So an underlying problem is that your file format does not match your processing code.

For clarification, the only difference between a 'binary' file and a 'text' file in C is that a text file stream will convert the platform's newline sequence into '\n'. You can use fread/fwrite on a text stream and fscanf/fprintf or any of the texty functions on a binary stream. I think one confusion point of C is that binary-oriented streams are somehow special, which they're not.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Forum technology is outdated.

And what's the 'modern' technology? Heavily policed Q&A that discourages meaningful discussion? 140 character brain farts that are devoid of intelligence? Useless videos flooded with trolling commenters? ;)

StackOverflow is a forum, though it's presented in a different way than most other forums and imposes draconian policies to enforce 'quality'. But that enforcement also squelches any hope of SO being more than a clique of power hungry douchebags offering little to no pedagogical value for beginners.

New is not always better, and if Daniweb ever throws away the founding principles to be popular with Google, that's the day I'll leave.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It works okay for me in Visual Studio after fixing two bugs. First you never initialize listA in main, so the top and bottom pointers are unintialized. A quick fix is this:

listA = malloc(sizeof(list));
listA->top = listA->bottom = NULL;

Second, and a more subtle problem is in buildNode. The logic is fine, but the amount of memory allocated is incorrect. sizeof(node) gives you the size of a pointer, not the size of the _node structure which is what you need. The change is trivial, but not obvious:

node = malloc(sizeof *node);

Now, while you could say sizeof(struct _node), it's generally better not to depend on a type name on the off chance you end up changing it by renaming the type or using another type. The trick above depends on the fact that sizeof does not evaluate the expression itself, only the resulting size. Otherwise, dereferencing an uninitialized pointer would invoke undefined behavior. However, in this case it's both perfectly safe and conventional.

This bug is a side effect of hiding a pointer in a typedef, which is generally not recommended precisely for reasons like this.

Note that I didn't crash in the same place as you did. There's really nothing wrong with printList, so getting an error there is a false positive and one needs to dig deeper in a debugger to find the real problems.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

...

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i dont wanna use Third Party Image viewer control

Then your two options have become one option. You'll need to use a third party library to convert the image to a format PictureBox likes. I say a third party library because .NET's built in imaging libraries may likely still cause you problems due to lack of support for the source image type.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

BindingSource is your friend:

private BindingSource _bs = new BindingSource();

...

// Initialize DGV
_bs.DataSource = ds.Tables("Customer");
dataGridViewCustomers.DataSource = _bs;

...

// Filter DGV
_bs.Filter = string.Format("customerID LIKE '%{0}%'", customerID);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Your dequeue logic has two major problems:

  1. It does not take into account updating the bottom node.

  2. Wherever the node is deleted, the list is terminated with NULL rather than maintaining the structure if there are subsequent nodes.

This is a basic single linked list deletion, so you might be well served by boning up on linked lists in general.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You've encountered one of the most irritating things about .NET (at least for me): image processing is quite wanting. I don't work with TGA much, but I work extensively with TIFF. The .NET imaging libraries either do not support TIFF readily, such as PictureBox, or the support for conversion of certain types to BMP such that PictureBox would accept it is lacking. A good example is JPEG compressed TIFF. Neither the old style .NET imaging classes nor the much superior WPF imaging classes (which can be used in WinForms) support that compression method.

Long story short, you have two options:

  1. Use a more robust imaging library such as Magick.NET to convert your TIFF and TGA images to BMP so that you can use a PictureBox directly.

  2. Find a third party image viewer control that will support the image types you need.

Either way you'll find yourself using a third party library for the heavy lifting.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That code is definitely C#. Since the question did not ask about conversion to C, I've moved the thread to the C# forum so that the resident experts have a better chance of seeing and answering it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What does it exactly mean to "escape" a string and where does the code for this go?

Escaping a string means converting characters that would be treated as special in a query as literal characters. A good example is a single quote. This has special meaning in a query, and attackers can use it to alter the functionality of the query to bypass security. Escaping that character makes it non-functional as part of the query such that it only contributes to a string value. Details on that can be found by studying SQL injection attacks.

As for where it goes, anytime you build a query with uncontrolled values, those values should be escaped.

After I have this set up in my code, how do I properly test that it is indeed working (Without completly wiping out my tables, etc?)

My preference is a combination of extracting the final query for manual testing, and extensive use of a test database so that the integrity of your production database isn't affected during development.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You seem not to get the point Dani

The point is not lost. I understand exactly what you want, and I'm sure Dani does as well.

why not make who voted visible (but only to post author)?

Let's attack this from another direction. Why do you need to know this information? What would you use it for?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

no dev window is closed. Why?

It's called troubleshooting. I'm asking potentially relevant questions to pinpoint why your browser isn't exhibiting normal behavior. Last night I tested the top 5 browsers (Chrome, FireFox, IE, Opera, and Safari) and they all function as expected.

Anyway, since Ctrl+Tab and Ctrl+Shift+Tab are both built-in shortcuts in all major tabbed browsers, we cannot use those combinations to do something different on a page. It would be like trying to override Ctrl+Alt+Delete in a Windows desktop application. Possible, but generally a bad idea.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I disagree with the part abut quoting.

Then we'll have to agree to disagree for now.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Quoting; add quote button to post/article header, so it stays there at all times,

This would only serve to quote an entire post, which in many cases would be excessive given that a large portion of our threads contain potentially long code blocks. Believe it or not, Dani and I actively discussed that particular feature and discarded it because it didn't fit into the most common use cases for quoting.

Tabstops; users are acustomed with template: TAB key = next tabstop; edit field should be included in tabstop count;

I disagree. Users would be very irritated by this behavior when focus is on a text editor control. Something can probably be done to offer a keyboard option to exit the editor though.

Autoscrolling of edit field: cursor should follow enter key; enter should scroll screen so cursor should stay visible all times without need to scroll manually;

This sounds like a bug, in which case we'll need a solid reproduction scenario to have any hope of correcting it. It looks like Dani already has plans for getting that scenario, so we can call this 'in progress'.

Who voted how should be visible: for exaple as mouse hover for vote count;

Votes are anonymous for a reason. There are no plans to change that currently.

Editor buttons and tooltips: now there are shrtcuts in tooltips, but there should be at least short description what hovered button does;

That's a reasonable feature …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Mozilla disagrees with you. Ctrl+Tab navigates to the next tab, and Ctrl+Shift+Tab navigates to the previous tab. If your behavior is different, that could be something about the dev edition, or you have an extension installed that changes default behavior, or some other application is running that captures and interprets key strokes.

When visiting Daniweb, do you have any of the developer tool windows open?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What browser and version are you using?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

what software this applies to?

All major browsers that support tabbed pages. When we're talking about Daniweb, it's fairly safe to assume that the hosting browser is the most relevant software involved. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Alt+s works for me, no shift necessary. I'm also on Windows 8.1. What browser are you using?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why you dont want to introduuce new features suggested by me (and not only me)??

You're sending mixed signals. First you want the bugs fixed before adding new features, then you want new features. In both cases, your suggestions have been too vague to act on. In fact, I haven't read any recent feedback posts of yours that do much more than rant on things you personally don't like.

So please, give us details:

  1. What do you think is a bug?
  2. Why do you think it's a bug?
  3. What specific behavior would you rather see?

For features:

  1. What behavior do you feel is missing?
  2. Please describe the behavior you'd like to see in detail.

If something fundamental is missing, there may be a good reason for that. Assuming that we don't care about members or don't do anything about feedback is unfair.

Things like "Daniweb doesn't do what I want", or "Daniweb isn't like other forums" lack any kind of actionable information. Further, by mixing suggestions with vitriol it's more difficult for us to extract any actionable information or treat legitimate suggestions seriously because it reeks of trolling.

I can assure you that Daniweb's feature set is certainly in flux relative to member feedback, provided that feedback is specific enough to be usable.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So are you one of the 11 million and will you still be on July 15th?

In my experience working with a number of companies as customers, Server 2003 has almost entirely been replaced with Server 2008 R2. I can only think of two customers that still have an active 2003 server, and both of them are either in the process of decomissioning it or have a roadmap for doing so within the quarter.

XP as a desktop system is run across the board of use cases, so you need to take into account everyone from business users to granny's sewing room machine, which makes end of life more of an issue. For the server operating systems, typically only knowledgeable folks run it, it's in a relatively high profile position on the network, and will have a reasonable maintenance/upgrade schedule.

So my personal opinion is that this end of life isn't as big of a deal as XP's end of life because lack of publication doesn't correspond to lack of awareness.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The problem is that a naive atoi like conversion won't work directly with hexadecimal characters because you need to take into account that a-f represent 10-15. That too requires a minor conversion as well to get the values you need. Once you have those values, this formula works to build a 2 digit hexadecimal value:

16 * first_digit_value + second_digit_value

I like to implement that minor conversion with a string search in the set of available digits. For example:

#include <cctype>
#include <iostream>
#include <string>

using namespace std;

int hex_digit(char c)
{
    return string("0123456789abcdef").find(tolower(c));
}

int main()
{
    char buffer[4] = {'3', '1', '4', 'C'};

    for (int i = 0; i < sizeof buffer; i += 2)
    {
        int digit = 16 * hex_digit(buffer[i]) + hex_digit(buffer[i + 1]);

        cout << (char)digit << '\n';
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A continuation would help in identifying a pattern. Presumably, it might look something like this:

1
1 2
2 3
2 3 4
3 4 5
3 4 5 6
4 5 6 7
4 5 6 7 8
4 5 6 7
3 4 5 6
3 4 5
2 3 4
2 3
1 2
1

But confirmation of that would be helpful. Otherwise this looks like a fun problem.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Markdown itself is just a text format, it doesn't regulate how web elements work together that I'm aware of. That said, I wouldn't be surprised if a number of Markdown-compatible editors do offer that feature. Ours does not, last I checked, so we would need to make further customizations to incorporate it. Off the top of my head, it wouldn't be a trivial change. Not impossible, certainly, but not as simple as flipping a switch.

To be useful the button would need to be persistent in the user's options rather than ad hoc, otherwise I'd question the viability of enabling/disabling tabbed focus by clicking a button versus simply clicking out of the editor. ;)

I don't disagree that the option is possible, though I'd be very interested in seeing statistics on how many people would actually use it. If only a handful of folks out of ~1M members would then I can't see the benefit justifying the cost of development. Though Dani might throw it in during one of her late night hacking sessions just because. It's happened before.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's by design. The editor isn't a mere text field, it's an actual text editor supporting Markdown where indentation is significant. If tab moved to the next page element, creating code blocks manually would be tedious at best.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Hmm. Of the top of my head, I'd say it really depends on what features you plan to support. If there's a huge amount of intersection between the two, I might choose to implement the vector as a composition/specialization of a matrix of 1xN or Nx1. Alternatively, a matrix may be a construction of vectors if that turns out to be more efficient.

I might not even split the two at all and let the caller use the matrix as a vector if there aren't any vector-specific operations (or manually construct a matrix out of vectors, but that seems less useful mathematically).

It's personal preference, of course, but I tend not to rely on inheritance unless necessary. Composition or careful generalization tends to cover most of my needs.

ddanbe commented: Great help. +15
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i mean the output should be vertical direction

Which means what, exactly? Show us an example, because right now each number is output on a separate line, and that looks a lot like 'vertical' to me.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What have you done so far?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Your else clause is missing braces. That only works when the body of the clause has one statement, yet here you have (presumably) three.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

can you please tell me which are those

newarr in main and newarr in extend are two completely independent variables. They contain the same value originally, but then you replace the value in extend with the result of malloc. That memory block is neither returned back to main nor freed, so it's a memory leak.

Worse, because it's not returned to main, newarr in main remains uninitialized and any attempt to dereference it is theoretically a segmentation fault.

why Valgrind couldnot find them?

Good question. Valgrind should at the very least be able to tell you that you make two calls to malloc yet there are no calls to free. My guess would be that it wasn't running memory checks.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There are a few problems, and most of them stem from misunderstanding pointers.

On line 12 you have this:

while(i <= cnt)

That's an off by one error. Arrays are 0-based in C, which means if the user enters 3, you're processing the indexes 0, 1, 2, and 3 rather than just 0, 1, and 2. It should simply be while (i < cnt).

if (arr[i++] == 0) *zeros++;

This is the first pointer related problem. *zeros++ will dereference zeros, then increment the pointer, not the pointed to value which is what you really want. Precedence and order of operations can be a little confusing when pointers are involved, but you can do either (*zeros)++ or switch to prefix increment with ++*zeros to get the correct behavior. Also note that you never initialized *zeros to 0, so its value is garbage.

The zero check also contains an off by one error in that you neglect to check the first value in arr by both incrementing arr during input, which is prior to the zero check.

I'd also question what the point of making zeros a pointer here as you could just use a straight up int and return that rather than mucking about with malloc and a pointer.

Finally, the global cnt smells bad. You should avoid global dependencies whenever possible, which in this case it most certainly possible by passing the size of the array as a parameter:

int readInts(int *arr, int cnt)
{ …
ddanbe commented: Nice work done here! +15
Slavi commented: kudos +6
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What do you need help with? What have you done? This is clearly homework, so we need some proof of effort before helping (as per Daniweb rules).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What do you have so far?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Creating controls at runtime is certainly possible. For example:

using System;
using System.Drawing;
using System.Windows.Forms;

namespace FormScratch
{
    public class MainForm : Form
    {
        private Button buttonAddImage;
        private FlowLayoutPanel flowLayoutPanelThumbs;

        private void InitializeComponent()
        {
            buttonAddImage = new Button();
            flowLayoutPanelThumbs = new FlowLayoutPanel();
            SuspendLayout();

            buttonAddImage.Location = new Point(13, 13);
            buttonAddImage.Name = "buttonAddImage";
            buttonAddImage.Size = new Size(75, 23);
            buttonAddImage.TabIndex = 0;
            buttonAddImage.Text = "Add Image";
            buttonAddImage.UseVisualStyleBackColor = true;
            buttonAddImage.Click += new EventHandler(buttonAddImage_Click);

            flowLayoutPanelThumbs.Location = new Point(13, 43);
            flowLayoutPanelThumbs.Name = "flowLayoutPanelThumbs";
            flowLayoutPanelThumbs.Size = new Size(680, 444);
            flowLayoutPanelThumbs.TabIndex = 1;

            AutoScaleDimensions = new SizeF(6F, 13F);
            AutoScaleMode = AutoScaleMode.Font;
            ClientSize = new Size(705, 499);
            Controls.Add(flowLayoutPanelThumbs);
            Controls.Add(buttonAddImage);
            Name = "Form1";
            Text = "Form1";
            ResumeLayout(false);

        }

        public MainForm()
        {
            InitializeComponent();
        }

        private void buttonAddImage_Click(object sender, EventArgs e)
        {
            using (var dlg = new OpenFileDialog())
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    flowLayoutPanelThumbs.Controls.Add(new PictureBox()
                    {
                        Image = new Bitmap(dlg.FileName),
                        Size = new Size(100, 100),
                        SizeMode = PictureBoxSizeMode.Zoom
                    });
                }
            }
        }
    }
}

Is there any way to "package" the image in the program?

Yes. You can add the image to your project as either content or embedded resouce with Add | Existing Item and then changing the properties of the item. For content, be sure to include the project content in your installer and the image will be copied to the installation folder. For embedded resources, it's only marginally trickier to reference the image.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But I cannot accept to call a language or platform "powerful" when the closest you can reasonably get to the "best" solution is ridiculously far from it.

No offense, but that perspective is also one based on tunnel vision. I'm often amused when people that would advocate using the best tool for the job turn around and attack those same tools by actively ignoring their target domain.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

All I see is a homework assignment, which violates our rules. Please show us your honest attempt and ask an actual question.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Complexity theory isn't easy unless you're a math whiz. I always preferred a more practical approach, which I've described here. But it looks like you already have those basics essentially down, and that article doesn't really delve into when and why to apply complexity analysis.

Most other reasources I've seen are heavy on the math and light on practical usage, though this blog was a refreshing read.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

the best monitor is what you like the best, at a price you can afford

Much yes. I'm a fan of Acer LED monitors, personally.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

sorry, but both of those languages are FAR from secure.
(I can decompile both of them with 1 finger)

I think it would be good to define what you mean by 'secure'. If you mean disallowing third parties to reverse engineer or otherwise steal code, then you're correct that by default those languages are not secure. Though there are ways to obfuscate assemblies to make such actions more difficult. However, it's not impossible to reverse engineer any software, regardless of what language it was written in. The only difference is the effort required to do so.

If by 'secure' we're talking about the more conventional cracks and exploits then I'd point out 'security by obscurity' is the pinnacle of naiveté. That kind of 'secure' is deeper in that holes are avoided through robust code, use of secure libraries, and in the case of .NET or Java, a safe runtime environment. The language itself has little to do with being 'secure' unless its definition encourages unsafe practices. But that's a much more in-depth discussion than just saying "XYZ language is FAR from secure" because there are many variables involved.

Simply being able to easily decompile an assembly does not make the assembly insecure in terms of creating an exploit, because transparent code doesn't inherently contain exploitable holes. If that were the case, open source would be stupid.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well, one thing that stands out immediately is C isn't so pretty that it allows commas in a large number. In fact, if you're exceptionally unlucky (which it seems you are), including them will be syntactically correct but semantically bonkers.

gusano79 commented: aaaand how did I miss that? +10
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but I use ++ for pointers and it worked my compiler is microsoft visual c

It works for typed pointers, but not pointers to void even if you cast them.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Help yes, do work for you, no.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You've mostly got it:

#include <stdio.h>

int main(void)
{
    int k = 80;
    void *p = &k;

    printf("%p\n", p);

    // Move forward one byte
    p = (char*)p + 1;

    printf("%p\n", p);

    return 0;
}

The result of a cast isn't a suitable lvalue, so you cannot use the ++ operator. There's also no need to cast back to void* after the operation because C handles that for you.

However, note that there are a number of risks involved in type punning like this, not the least of which is that the order of bytes in an int is platform dependent. Also, while punning to char* is generally safe, punning to any other type can easily generate an error condition such as a trap representation or mis-aligned value. So take great care in applying this trick.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Just for my understanding, it means that the time complexity that we find using Big-Oh, Omega or Theta is not the actual execution time of the program?

Correct. The two are related, but not 1-to-1.

Also which method will be best from the above two methods

'Best' is subjective as it depends on your needs. However, if you're looking for execution performance with only those two options, I'd say the second is superior since you've already profiled it to be faster. ;) Further, by not removing constants you can more accurately judge the real performance difference of two algorithms. O(n) is extremely likely to be slower than O(n/2). The question at that point is how much slower, and deeper analysis of the work done at each iteration is needed to determine how significant that difference is.

Also the space required by second program will be more

The space difference is tiny and constant (one int variable), so I'd call it negligible unless you're working with an exceptionally limited environment.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Also if the time xomplexity of both the methods is O(n), then how is the second method runs faster than the linear search method?

Big O only tells you the expected growth rate of the algorithm, which in both cases is indeed O(n), not its actual execution performance. Algorithms with the same complexity can run in wildly different times because at execution time the constants matter.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Nesting functions is not supported in C++.