deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I live in the north metro area of Atlanta.

The .NET users group meets at the Microsoft offices in Alpharetta. If nothing else it's a good way to network with other developers and ask about targeted courses. I wish I could say I'd see you there, but I'm too lazy to drive even from Marietta to Alpharetta for the meetings, so I've never gone except on business. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In hindsight, I should have mentioned that before. Oh well.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If you're still using the above code, then inname hasn't been initialized. However, you won't have any problems with it unless you enter the case of a file not being able to be opened (ie. infile is NULL).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That program was an example, not a solution to your exact problem. You're supposed to learn from it and use it as a template for constructing a program that does solve your exact problem. I won't do your work for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The simplest approach would be fgets() and strtok(). Here's a quickie example:

#include <stdio.h>
#include <string.h>

int main(void)
{
    FILE *in = fopen("test.txt", "r");

    if (in) {
        char line[BUFSIZ];
        char *tok;
        int i = 0;

        while (fgets(line, sizeof line, in)) {
            line[strcspn(line, "\n")] = '\0'; /* Trim the newline if present */
            tok = strtok(line, ",");

            printf("Line #%d\n", ++i);

            while (tok) {
                printf("\t'%s'\n", tok);
                tok = strtok(NULL, ",");
            }
        }
    }

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

Buy a book on HTML and work through it? Rinse and repeat for other "web programming" topics.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But it still reads the hole file.

If the code you posted is the code you're running, then the file has 10 lines or less. On the off chance that I'm stupid and failed to properly compile and run your code in my head, I tested it here and it worked perfectly.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But why the break in the default is needed?

default isn't special from a syntax standpoint, it's just another case. The reason a break is required is the same reason it's required in other cases, due to the fact that default isn't required to be the last case in the switch statement. A less common but equally valid positioning is the first case:

switch (a)
{
    default:
        Console.WriteLine("We are here");
        break;
    case 1:
    case 2:
        break;
}

And there's no requirement that default not be somewhere in the middle, though it's more confusing to read, of course. The designers of C# could have added an exception such that the last case in a switch statement doesn't require a break, but that would introduce more complexity to the language, the compiler, and force programmers to learn yet another nuance. I'd guess this was the reason it wasn't added.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

by the way why do you use the name deceptikon?

There's no real reason, I picked it on a whim. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So how do I read only 10 line of input file.

Create a variable that counts to 10:

for (int i = 0; i < 10 && fgets(line_buffer, sizeof(line_buffer), infile); i++)
{
    printf("%s\n", line_buffer);
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I faced similar issue transferring CSV file into database, but after splitting the string using String.split() function the files are properly inserted into the table.

Until you're given a complex CSV file where one or more fields contain embedded commas or line breaks. ;) The ReadLine() and Split() approach is viable only for simple "CSV" files where the only commas are separating fields and the only line breaks are the record terminator.

Begginnerdev commented: I have had nightmares about complex CSV files... +8
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can you post a sample of the CSV file?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My question is how do you run a c file or c++ file in vs2012 with out creating a solution.

Run the compiler from the command line. I'm not aware of any out of the box way to do it in the IDE, but you could create your own external tool that runs cl.exe on the selected open file. If it's just one file, I'll just copy/paste the contents into my scratch project.

Also how do you creat a solution for ready created scoure codes

Create the project, then add existing files as opposed to new files. There might be a utility out there that generates a solution from the contents of a folder automatically, but you'd have to search around for something like that. I just do it manually.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Just use the file name and not the full path in the query. The path without the filename would go in the connection string. Here's a working example you can use as a template if you'd like:

    Private Function CsvGenerateView(filename As String, hasHeader As Boolean) As DataSet
        Dim connectionString = String.Format( _
            "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""{0}"";Extended Properties=""Text;HDR={1}FMT=CSVDelimited"";", _
            Path.GetDirectoryName(filename), _
            If(hasHeader, "Yes", "No"))
        Dim query = "select * from [" & Path.GetFileName(filename) & "]"
        Dim ds As New DataSet

        Using connection As New OleDbConnection(connectionString)
            Using cmd As New OleDbCommand(query, connection)
                connection.Open()

                Using da As New OleDbDataAdapter(cmd)
                    da.Fill(ds)
                End Using
            End Using
        End Using

        Return ds
    End Function
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Umm, I think you should downvote a post, and then make someone else upvote it. It won't show in either place, "Buttons voted up" or down. :S

Yes, because neither post is currently positive or negative in that case. That's intended behavior, the up and down voted posts lists aren't for any post that has had a corresponding vote at some point in its history, they're for any post that presently has a positive or negative rating, respectively.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Please do inform me when the problem will be solved. :)

I can't make any guarantees or estimates yet. A quick test on my end shows the response to be immediate. So the problem is intermittent, and that makes it much harder to troubleshoot. :(

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It has been 2 and a half days, my friend.

I guess I'll do some code diving then. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The problem with instant/realtime updates is that they can hammer the server, and it gets worse the more notifications you offer. Your example was Facebook, but I can guarantee that Facebook doesn't have the same server and database limitations that we do, and keeping the site responsive (not to mention avoiding crashes) is somewhat important. ;)

I agree that it'd be a great feature, I'm just not sure it's feasible at the moment.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I ban you for lack of creativity.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

When does it pop up? What were you doing at the time? The only time I'm aware of that this should happen is when you create a new article.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think posts with a net rating of zero should not be considered in the overall posting quality.

Just because the post has a net rating of zero doesn't negate the fact that it has votes applied. Your suggestion would take the value of votes away such that you'd be saying "someone disagrees with your vote, so your opinion doesn't matter".

Now, on the profile, n(posts voted down) is one, but when I, for example, click on the "View posts voted down" button, the post is not displayed because its net rating is zero. Please resolve this

I'll look into it, but I suspect it's more of a timing issue as the update propagates through the system. If you check back after a day and it's still not correct, let me know, because that's way too long.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

as long as it's not written by Herb Schildt...

Much as I despise Herbie's stuff, I'd go so far as to say that learning from any book is better than sitting on your ass and twiddling your thumbs. Bad habits can be unlearned, but not learning in the first place is a shame.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is it in case of logical operators only or every binary operator??

I could have sworn I clearly said "the logical operators are short circuiting". If other operators had that behavior, I would have mentioned it. So yes, it's only in the case of logical operators (&& and ||). Technically the conditional operator (?:) is also short circuiting, but that's so obvious and intrinsic to its behavior that there's little meaning in pointing it out.

Because since i Have mentioned the brace for && operator to make it execute first..In case of other binary operators like arithmetic ones you can increase the priority by specifing braces as in case of a=4*(5+6) here + will execute first then why dosent that happen in case of && operator in my expression

I could have sworn I clearly said "it doesn't work that way", and then went on to explain how it did work with logical operators. If there's a part of my explanation you didn't understand, please point it out and I'll try to elaborate. But please don't completely discard everything I said that answered your question and then ask the same damn question again.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I am planning to promote my blog through blog commenting.Is it a good idea?

If your comments contain substance and aren't just a veiled attempt at spamming your blog, it's a great idea. Otherwise, you're more likely to piss people off and ensure that they never visit your blog because you'll be labeled as a spammer.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If hacker could intrude into such an expert coder's app, then their might be some faults on PHP's side right?

Your conclusion is reasonable but your premise is not. Even experts make mistakes. Case in point is Knuth's reward for mistakes that has resulted in more checks than one might expect for an expert of his level. In fact, I'd be more inclined to blame the programmer than the implementation of a popular programming language simply because of the sheer number of people using the language in stupid ways that would highlight bugs.

Plus i have never heard ASP.NET or JAVA apps getting hacked.

I have...a lot.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Athough I am specifying the braces for the && operator so that it gets executed first.

It doesn't work that way. The logical operators are short circuiting, and they always execute left to right. Those two features together mean that the left side of your || statement will always occur first. Because that test evaluates to true, there's no point in executing the right side; the final result is known, and side effects on the right side are immaterial as far as the logical tests are concerned.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't know how to use it.

Then this is a good time to learn how to use it. Believe it or not, most programmers don't know how to do everything required to complete a project when they start; they learn it as they go.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's an easy one because it's nothing more than a derivation of quadratic complexity. For example, if the number of dimensions, call it m is 2 then you have classic quadratic complexity: O(n^2). If m is 3 you have cubic complexity: O(n^3). Thus you generalize for any value of m by removing the constant and replacing it with a variable: O(n^m).

especially about the step count and loops and the growth rate of big-oh

Sequential stuff constitutes addition and nested stuff constitutes multiplication. So two sequential loops would not affect each other in Big-O because they're simplified into the one that has higher growth. For example:

for (int i = 0; i < n; i++) {
    ...
}

for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
        ...
    }
}

These two loops are additive, with the first being O(n) and the second being O(n^2). So you have precisely O(n + n^2). But Big-O removes the lower order parts because the higher order parts totally overwhelm the complexity very quickly, and thus the example above has quadratic complexity: O(n^2).

The second loop has quadratic complexity because the nested loops are defined in terms of each other. You multiply the complexity of the inner loop by the steps of the outer loop to get the total complexity. Since they're both in terms of n, it's a simple matter to say that the two loops combined have …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm not sure I understand the question. What do you mean by the "order" of the array? Do you mean how to traverse a 1D array of 3125 elements as if it were a 5D array of size 5 for each dimension? Or do you mean how a 5D array might store those elements in sequential memory? Or something else?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I wouldn't put them on your resume, but if they're good examples of your ability I'd include them in a project portfolio for interviews.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Console.Readline(); by itself will pause the console.

Any input request will pause the console, but if your goal is to 1) not pollute the console's output and 2) accept any key press for continuing, then ReadLine() isn't ideal because it echoes the characters you type and requires the Enter key to finalize the request.

The canonical getch() is what you'd want, and conveniently enough .NET standardizes that behavior with Console.ReadKey() and a false parameter to disable echo.

ddanbe commented: I cannot do other then rep you +14
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

so i am using getch(); it shows error and even for systemn("pause");

Neither of those are valid in C#, they're C/C++ functions. How are you running this program? Anyway, if you must do it, use Console.ReadKey(false) to simulate getch().

On a side note, if you're not willing to read the documentation before trying random things and then asking for help, I'm not willing to help you fix the mess you create. Keep that in mind and RTFM as a first step in troubleshooting any problem.

this is the code which i changed according to your program

Works for me.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

sum = sum + size;

This is meaningless, it has nothing to do with summing the values in the array.

sum = Convert.ToInt32(Console.ReadLine());

This is counterproductive, it destroys whatever value was already stored by sum. Look very carefully:

Console.WriteLine("the sum of elements are");

for (size = 0; size < 10; size++)
{
    sum += arr[size];
}

Console.WriteLine("sum:{0}", sum);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

First, make sure you understand the syntax of connection strings and ensure that yours is correct. At a glance it looks fine to me (but don't take my word for it), so my next step would be to check your Jet 4.0 provider's version and install all necessary redistributables/patches to get yourself up to date.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

please can u correct my program and tell my mistake please

If I do your work for you, you won't learn. I've already told you your mistake (you don't output the sum and you unnecessarily overwrite the sum at the end). Please refer to an earlier post of mine in this thread where I provided a correct and working snippet. Modifying it to use an array shouldn't be too difficult.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's because you don't output the sum...ever. In fact, you undo all of the work of the program by overwriting the sum at the end.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That error typically pops up when your connection string is malformed or the machine doesn't have appropriate Jet drivers installed.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You don't need an array to sum numbers that are coming in sequentially, but you do need to accept those numbers properly in turn and accumulate them in the sum:

int sum = 0;

for (int i = 0; i < 10; i++)
{
    sum += Convert.ToInt32(Console.ReadLine());
}

Console.WriteLine("Sum: {0}", sum);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A flowchart is (or was - who the hell still uses flowcharts in the 21st century?)

I use them often. A whiteboard and an informal flowchart are handy for wrapping your brain around complex algorithms. They're also very useful for business process and workflow because business types (and techie types distressingly often) need pictures to understand what the hell you're talking about. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You need to divide and modulo by 16 instead of 8, and you need to use the letters 'A' through 'F' when x is greater than 9. A fun trick is with a table lookup of digits:

public static void convert(int a){
    String digits = "0123456789ABCDEF";
    String obrnuti = " ";

    while (a > 0){
        int x = a % 16;
        obrnuti += digits.charAt(x);
        a /= 16;
    }

    System.out.println(reverse(obrnuti));
}

you're making it way too difficult.

That's all well and good, but it's not unreasonable to assume that a teacher is disallowing use of the standard library for this exercise.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's up to the browser, of course, but typically they're organized by domain. Put simply, a website's domain is know, so it's trivial to match the website with its cookies.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Just pick one. It's better to start with something than to sit idly by and wait for the ideal learning material or path.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You're trying to use the subscript operator on an empty vector. A vector is not an array, and you need to take care go make sure that there's enough room before indexing one. Consider something like this instead:

void insertItem(int k, const ElemType& x){
    A.push_back(Item(k, x));
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i got the code from internet, but i wonder why is it not working. can somebody please help.

Read the thread you posted to, then follow the advice. Your problem is not unique.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'd wager you haven't set NetBeans up correctly to compile and run C programs.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So basically in order for my code to work everything I have do everything within the header file?

Yup.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

ld: symbol(s) not found

That means the linker doesn't see a definition for the stated function or method. After actually looking at your code, you can't split up a template class into multiple files like that. The method definitions must be in the header.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The "errors" you posted are part of the stack trace, not the actual error message. Can you post the entire thing?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It can't find the file. I'd suggest trying perror() to get a little more information:

if (!file)
{
    perror("Error opening file");
    return 0;
}

perror() is declared in <cstdio>, so be sure to include that header. Most likely it'll say something like "file not found", in which case you need to track down the issue that Nathan mentioned, which is placing the file in the current working directory. The current working directory is usually where the executable resides, but sometimes it could be a debug folder if you're using an IDE.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I had been away such a long time, i didn't ever notice when that option was added.

It's always been there. ;) Under vBulletin the feature was called thread subscription in your control panel's options section, and under Daniweb's custom system it's automatically watching articles from your edit profile page. We added that feature before the migration from vBulletin to the current system.