deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Does "int32.TryParse()" bring back a True/False answer?

http://msdn.microsoft.com/en-us/library/system.int32.tryparse.aspx

Regarding "DBNull.Value", do I write that as

No, you use it when actually writing to the database. Your title suggests that you're writing to a database, but you're focusing on what looks like validation code that runs first.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

why is there more than one way to do something?

In any language that's suitably powerful to be called general purpose, it's pretty much impossible to avoid multiple ways of accomplishing something.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I rather like NetBeans, from the selection of free tools.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

When the user bypasses entering anything within those textboxes (as they should do), what is the correct way to handle the reporting?

If null values are acceptable in the database then you can write DBNull.Value when the string is empty.

Is there a way to determine if the characters within "txbSpecialCost" are Alph or Numeric characters?

Yes, though if you're looking to validate numeric input I'd suggest either a NumericUpDown control rather than TextBoxes, or validate by trying to convert to the numeric type with something like Int32.TryParse().

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is there something I'm missing here?

Unfortunately, I'm not familiar with Objective-C, so your best bet would be to post your current code to the Objective-C forum so that the experts there can help out.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You could certainly write a background service that ticks seconds and runs at startup, but pretty much every modern OS will provide a way to query uptime. What OS are you targeting?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Unless you do want to discourage beginner/intermediate programmers to try to help out, I think you might want to take a more patient approach to dealing with them.

In the case of beginners who know close to nothing, won't admit that they know close to nothing, and stubbornly insist that they're neither wrong not clueless, I'd prefer that they didn't help until they have a bit more experience.

You'll notice that the vast majority of beginners who try to help are encouraged. So maybe you should consider why we were giving this one such a hard time. Be sure to read all of his posts for a complete perspective.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Enter key is stored in the buffer of getchar as '\n' or '\r'??

'\n', always. Even if the underlying representation for the system is different (such as CRLF on Windows), getchar() will convert a newline to '\n' for you. That works for output too, so '\n' will become the system's newline sequence.

The problem with the output is that the input is displayed 3 times! I expected two times because of the 2 printf's but I can't understand why 3 times???

You'll need to say exactly what the input is for me to be sure, but I suspect you're confusing the echo of typing the characters with the actual output from printf().

Do the comparisons occur in the order I specified??

Yes. Further, because of the short circuiting behavior of the && operator, it's guaranteed that the sequence of tests will end on the first comparison that fails. So if getchar() returns EOF, i won't be tested for 32 and ch won't be tested for '\n'. If getchar() succeeds but i is 32, ch won't be tested against '\n'.

Also, if you reduce the size of the array to say 3 the while loop keeps on looping and asking for characters even when 2 characters are specified and the loop should break because of the i<3 comparison. I also can't figure that one out!!!

It's hard to guess without seeing an example.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

row[2] and row[3] are already doubles

In a DataRow, they're objects. They may actually be doubles, but the immediate representation is Object as stated by the documentation for the index operator, so you must do a conversion.

Your solution is funky because double.Parse() requires a string argument. You can make it less funky by using Convert.ToDouble(), which has an overload for Object:

tempdata[i] = Convert.ToDouble(row[2]);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Which require stronger social skills Programmer or Network Administration

Having done both, I'd say suck it up and work on your social skills, or find a different field. In all seriousness, social skills are needed as either a programmer or a network admin. If you don't have them and have no intention of developing them, you'll have a very hard time being successful.

From what I've seen of entry level programmer when I was a mail clerk they didn't do to much talking. Just coding in a cubicle.

It may seem that way, especially in organizations that don't do things like pair programming, but communication is paramount unless you're the only programmer and the only client for a project.

ddanbe commented: Well said! +14
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Cout is declared in the iostream header file, so what does it mean that cout is declared in the namespace std?

It sounds like you think namespaces and header files somehow conflict, and that's not the case. You can think of it as headers being the physical home of declarations while namespaces are a logical home. Notice in my example for <iostream> that the std namespace is defined inside the header, and the objects are defined inside the namespace. Basically when you say something like this:

namespace std {
    extern ostream cout;
}

What really happens is as if you defined a unique name somewhat like this:

extern ostream std_cout;

All namespaces do is add a layer of uniqueness to names so that the same name can be used in different namespaces. However, instead of forcing you to define names like std_cout, the language provides scaffolding to do it for you as well as simplify use of the names with things like using namespace std.

Also note that a namespace is collective, so you can define parts of it separately:

namespace std {
    extern ostream cout;
}

namespace std {
    extern istream cin;
}

And the compiler will combine everything so that the result is as if you defined everything in a single namespace definition:

namespace std {
    extern ostream cout;
    extern istream cin;
}

That's why I could just declare the stream objects in the namespace definition for <iostream>, …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

type is a variable that you neglected to define. Take a look at the main() function in my example, type is a string that's filled in from the user after being prompted for a membership type.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is not cout declaration exists in the iostream header file!

Um...what?

what it means that certain names are recognized in namespace std including cout is declared within it!!!!!?

I don't understand the question. Please rephrase it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Switch cases only work for integral values. Ideally you'd somehow check the string and convert it to a number, or just compare directly. For example:

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

using namespace std;

int type_index(string type)
{
    // Normalize the string to a consistent case
    for (auto& ch : type) {
        ch = (char)tolower((unsigned char)ch);
    }

    // Check the value and convert to an index
    if (type == "adult") {
        return 0;
    }
    else if (type == "child") {
        return 1;
    }
    else if (type == "student") {
        return 2;
    }
    else if (type == "senior") {
        return 3;
    }
    else {
        return -1;
    }
}

int main()
{
    string type;

    cout << "Enter membership type (Adult, Child, Student or Senior): ";

    if (cin >> type) {
        cout << "The membership type index is " << type_index(type) << '\n';
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The word 'cout'stands for console output.

It stands for "character", as stated by a somewhat authoritative souce. That's fortunate too, because if cout were named after and designed for consoles and screen display only, it would be vastly inferior to the general stream we enjoy today.

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

It's supposed that the sentence between the two quotation marks will not be targeted directly to the screen, but will be stored somewhere first before directed to the screen.

I'm guessing you mean the buffering mechanism. For performance reasons, because you don't want to communicate with devices (a typically slow operation) for every single character, output streams will implement a buffer that collects a certain number of characters before writing them all to the device en masse. Input streams do the same thing, except in reverse. An input stream will collect as much data as possible from the device and store it in a buffer, then dole out characters to your program as requested. This way the device is invoked less often without affecting functionality.

What is that place in which the sentence will be stored?

It depends on the implementation of the streambuf contained by the stream object. But it could be as simple as an array of characters in the streambuf object, or no buffer at all in cases where the stream is unbuffered.

What does it mean that the header file iostream contains the declarations that are needed by the cout identifier and the << operator?. What does it mean by the declarations? If with an illustrative example of this would be the best.

I can do one better. This is the iostream header in its entirety (barring variations per compiler):

#ifndef IOSTREAM
#define IOSTREAM

namespace std { …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Serializing objects like that is not safe unless you can guarantee that the class in question is a POD type. In the best case for something like std::string, you'd end up writing addresses pointing to data rather than the data itself. The actual data would be lost and the addresses would be meaningless when deserializing.

You might consider using something like Boost::Serialization, or manually serializing by writing ToString() and FromString() methods in your class, then serializing the string data. Which is better really depends on your needs.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I have inserted the pic that is showing correct format in the preview section

That's the editor itself, not the live preview. The live preview will be below the editor box unless you hide it by clicking on it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Unfortunately, that's what will happen if there's no place to deterministically place a word wrap. This is a case where you should proofread your posts in the live preview and make sure they're formatted the way you want, even if you have to add a space in that long line to force word wrapping.

Though I will take a look and see if a reasonable solution to long lines presents itself.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I found 9 errors in this program. I hope this will help.

That's much better, though still not especially helpful when looking at the OP from a position of understanding. I'll restate my original advice that you should learn before trying to teach. It's obvious that the "program" in the OP is only a snippet, it's not meant to be compilable as-is. As such, there are guaranteed to be compilation problems with unspecified global variables, missing headers, and the lack of a main() function. nitin1 isn't that much of a beginner, so pointing out such errors is unproductive.

Further, judging by the presence of the ans.push_back(p) and g[p].size() expressions, I'd wager that this code is actually C++ and the dfs() function is really a class method. Whether nitin1 wants C or not is a question that he'll have to answer though. I may need to move this thread to the C++ forum.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i declared 'n' aand 'k' global and i got success.

That means they're defaulted to 0 instead of given some random value.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are our speeds extremely slow?

Yes. But that doesn't mean your capacity is low, it just means that at the time you ran the speed test, the pipe was bogged down. I'm guessing you didn't run the test when your machine was the only one active on the net.

What's the speed of your connection as a whole? Meaning, how does your ISP describe it in terms of download and upload capacity?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In those cases either the program didn't expect input, or your code used reasonable default values. Did you try what I suggested?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

God forbid you post interesting content that people will like. I guess that's too much work compared to artificially increasing likes with silly things such as sock puppet accounts.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What I was saying was use cprogramming.com.

Thanks for clarifying the obvious. :rolleyes:

But also go on w3schools.com if you want to learn another program.

How is that relevant to this thread?

I bet you haven't even gone on w3schools.com. When you do you will see what I was talking about.

I've been there. I go there regularly. I'm certain that w3schools will not help nitin1 with the question he asked in this thread. And you've completely failed to specify exactly how you think it will help and included a specific link to the page you think will help rather than the home page.

At least helping a little bit is better than saying nothing!!

When you start helping even a little bit, I'll stop complaining that you're not helping. In fact, I'm almost to the point of treating you as a troll who's intentionally posting off-topic shit to get a rise out of people. People have flagged your posts as such to the moderation team, and I'm starting to agree with that assessment. And if/when I reach that point, I'll start deleting your posts and laying down infractions for Keep It Organized (probably retroactively to clean up the threads you're causing trouble in).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@ tinstaafl it is also working fine on my dev-c++ but why it giving RTE on ideone?

I suspect you're not giving the Ideone sufficient input to work with. Click the "upload with new input" button and add this:

5 1 2 3 4 5

There should be no errors and the output will be:

3
9
27
81
243
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I am not wrong! I put this program in my terminal, and it showed the errors!

Let me be more clear in what I mean by "you're wrong". You're wrong in that what you said to help the OP was wrong in every conceivable way. I have no doubt that you're getting errors on your "terminal", but I also have no doubt that it's because you're at a point in your own education where you have no business trying to help others.

My advice to you is learn before trying to teach.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I wonder is it safe?

As written it won't compile, so if you want to get technical it's perfectly safe as it'll never run. However, I suspect that you're paraphrasing. If definitions of those arrays are provided somewhere else then the code will compile and run.

Assuming a more complete example, it isn't necessarily safe because there are no provisions to avoid overflowing the arrays with a string that's too long. This is a classic problem with sprintf(), and the usual answer is snprintf(). However, snprintf() isn't a standard function prior to the C99 standard, so your compiler may not support it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If the only way you can "help" is by posting general and largely useless links, then you're not helping.

There is a website called http://www.cprogramming.com. This website can help a lot.

I'm very familiar with cprog.com, and I can definitely tell you that the only place you can get help on topological sorting is the forum. However, based on previous questions of that nature, it's not even guaranteed help.

If you want to learn more you can go to http://www.w3schools.com

Please point out exactly the page on w3schools that helps him, and explain how it helps. I know for a fact that w3schools has absolutely nothing relevant to this thread, so it's a completely off-topic and useless link.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I know a website that could help him!!

Please point out exactly the page on w3schools that helps him, and explain how it helps.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why are you so angry I'm just trying to help??

No, you're not. You clearly said you can't help, so how could your post possibly be construed as "trying to help"? Your link is totally irrelevant to the question about topological sorting. Given that your post is both off topic and completely pointless, I can only presume your intention was to boost your post count with meaningless posts.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Look I'm not saying anything bad?

You're not saying anything bad, you're just completely wrong. I suspect that the errors you're getting are due to how you're copying and compiling the code, not anything with the code itself, which is just a snippet and contains exactly one error on the stated 6th line. The problem is that the typedef is incomplete at the point where next is defined, and thus it cannot be used. The solution is to give the structure a proper tag and use that:

typedef struct Node
{
       int ordinalSum;
       int LexemeCode;
       Line Info;
       struct Node *next;
}Node;

Structure tags and typedef identifiers are in different name spaces, so they can both be Node. Easy peasy, but it's still a snippet, so you'll get errors if you try to compile it as if it were a complete program.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Sorry dude, but I think a good lesson for you right now would be to fail miserably because you relied too much on the kindness of others in doing your work for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I live spitting distance from Atlanta, so the only cost is the membership and whatever I'd spend on loot. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

And I am wondering is anyone anyone else cosplay?

I may do something for this year's Dragon*Con. Haven't decided yet.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This looks promising.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You need headers like
<math.h>
<stdlib.h>
<curses.h> or if you are using microsoft <conio.h>
<stdfx.h>
<graphics.h>
etc

If you don't know what you're talking about, please don't pretend that you do. Because those of us that know what we're talking about will see through it easily.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Need help

"Help" suggests that you're doing most of the work and others are providing assistance when you get stuck. However, posting nothing but a homework assignment suggests that your definition of "help" is closer to "do it for me". So please provide evidence that you've put in some effort, or our definition of "help" will be to direct you toward books and tutorials for beginners.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

ok so if use a==b instead of strcmp() this could solve the problem

Um, no. If you use a == b then you'll be comparing the address of two arrays, not the content of two strings. You do want to use strcmp(), but you want to use it correctly (as in my example), and with full understanding of how it works.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's a problem because your code will not compile as C, and if you ask questions in the C forum, the first thing you'll be told is one of the following (depending on how helpful and familiar with Objective-C the person is):

  1. Your code is not C and is wrong.
  2. Your code is Objective-C and you're in the wrong place.

If you want to learn C, learn C, not some bastardization of C and Objective-C that may not compile as either.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think I'll ask why anyway. Are you trying to reverse engineer an algorithm or something?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's not that simple. First, pick a graphics library. Then, learn how to use that library by reading documentation and examples. For Qt, I'd suggest starting here.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Then you'll need to learn how to use a modern graphics library like one of the ones I mentioned. If you're not using Turbo C on Windows (or MS-DOS), you're SOL for <graphics.h>.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That header is pretty much specific to Turbo C, and it's also ancient in terms of graphical feature support. I'd strongly recommend using something more up to date, like Qt or OpenGL. What do you want to use graphics for?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

pardon?

You don't know what indentation is?

can u tell in simple words what is the problem with my codes?

No. If you're not willing to put any effort into formatting your code so that it's easy to read, I'm not willing to put any effort into reading it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I personally think Dragonball and Outlaw Star both are improved by the English VA.

I might agree with Dragonball Z, if only because Goku's seiyuu doesn't seem to fit the character very well in my opinion.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Do you seriously work with your code unindented like that? So far all of your posts have zero indentation before some kind mod fixes it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why my images look messy?

Because we use CSS to align the images, it's not like a Word document. You'll need to organize the post so that it doesn't look goofy, much like you would in a web page. Note that we include a live preview underneath your post to facilitate proofreading.

I still don't understand about the 'inner loop depend on outer loop' mechanisms. How the calculations behind that or logical step or etc.....

I suspect what is meant is that the inner loop uses the counter from the outer loop:

#include <stdio.h>

int main(void)
{
    int i, j;

    for (i = 0; i < 5; i++) {
        for (j = 0; j <= i; j++) {
            putchar('*');
        }

        puts("");
    }

    return 0;
}

And to answer your first question, use two nested loops in sequence where the first prints spaces and the second prints stars:

#include <stdio.h>

int main(void)
{
    int i, j;

    for (i = 1; i <= 5; i++) {
        for (j = 1; j <= 5 - i; j++) {
            putchar(' ');
        }

        for (j = 1; j <= i; j++) {
            putchar('*');
        }

        puts("");
    }

    return 0;
}