but what does my output need to be.
According to the requirements you posted, output is not specified. Do what you want, or output nothing at all.
but what does my output need to be.
According to the requirements you posted, output is not specified. Do what you want, or output nothing at all.
Then you read the wrong article -- see the example here
That page says the same thing. ;)
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
Navigate to section 7.16.1.1-2 and you'll find this sentence: "The parameter type shall be a type name specified such that the type of a pointer to an object that has the specified type can be obtained simply by postfixing a * to type."
Don't run the .exe file? Anyway, that's not a "trick", it's legitimate code. There are innumerable ways a programmer can "trick" you with their code, and the solution is to avoid running programs from such programmers rather than expecting to somehow introspectively recognize the tricks in object code and "dodge" them.
Except for the invention of the Internet, the adoption of seatbelts, Michael Jackson, Knight Rider, and, of course, the invention of miniskirts. And the greatest miracle of them all, my birth ;)
Nifty things happen or are invented in every decade, but that doesn't make living in the decade equally nifty. ;)
For a beginner, what would you suggest I start with?
You can search google for a general overview on different programming languages as well as high level comparisons. I'd strongly recommend picking the language that interests you most, because you'll be more likely to stick with it. However, with that said, Python is a friendly language for beginners.
And are there any internet resources you could recommend as well?
Google and a lot of skepticism. It's surprisingly educational when you have resources with a wide range of quality and need to weed out the crap.
If one was to get into college for computer science, what other general classes do you believe would be helpful in that area, if any?
I'd suggest brushing up on algebra, linear algebra, and formal logic. Higher math helps but isn't required since it really only helps for nailing down certain concepts (like recursion) and proofs. It also couldn't hurt to do research on data structures and algorithms, because a lot of the CS course will stem of that stuff. Finally, a 10,000 foot view of how computers and communications work under the hood will help immensely. You don't need to understand everything about TCP/IP or exactly how a CPU works, for example, but you should have a rough understanding of the basics.
And I apologize if I came across as hostile.
By hostile I mean either intentionally or unintentionally (unintentionally, in your case) forcing us to work harder to help you. It doesn't mean I think you have a bad attitude or anything.
If they're data files, why are you trying to compile them?
Broad it was meant to be
I have some criticism for you. :) Specific questions get good answers. Broad questions go unanswered or attract flames. If you're asking for help, it's unproductive to be actively hostile in making it easy for others to help you.
I am interested in learning everything and anything about computers.
I'm interested in that too. But it's not realistic.
"Computers" is a broad subject. Can you be more specific?
What are 4.txt, 5.txt, and 6.txt?
Can it be possible to give the header file windows.h in turbo c ?
Note that simply getting that header would do a whole lot of nothing. A header typically contains delcarations and requires linking with a static or dynamic object library for those declarations to be useful in any way.
As AD said, your compiler is ancient and you're sure to encounter a number of issues when writing code for a modern operating system. Not the least of these issues is Turbo C is a 16-bit compiler, which greatly limits you even though your OS is 32 or 64-bit.
The 1980s weren't that great. Come join us in the new millenium.
Yes, I know they (argv strings) are modifiable, but IMO not a good idea! It is easy to force a buffer overrun, creating a potential security breach! :-)
Agreed, certainly. I've never encountered a situation where it was necessary to modify one of the argv strings, and honestly I agree that it's a bug waiting to happen. However, you don't have much flexibility in the signature of main(). Equivalent types are allowed, but char*
and const char*
are NOT equivalent types. So there's no guarantee that the compiler will accept this definition of main():
int main(int argc, const char *argv[])
{
...
}
If it does, all is well (such support is implementation-defined), but the code won't be portable. If it doesn't, you've invoked undefined behavior just as readily as using void main() on a compiler that doesn't support a void return type.
The getopt() function is a POSIX standard.
Which is wholely irrelevant when talking about portable C++. The world is not all POSIX, after all. ;)
You'll find that we're very patient. But at this point, if the algorithm isn't working it's because something is wrong with your code.
I did. Up above.
I wrote it out.
You posted pseudocode. Please post a complete C program that compiles and runs.
Also, argv should be a
const char*
not achar*
.
No, it should be char*
to be strictly conforming. Did you know that the strings in argv are modifiable?
The other is to loop through from 1 to argc and call the function getopt().
getopt() is not a standard function though.
I must confess to usually using the old style, simply because of 30 years of bad habits! :-)
I usually use an ad hoc method as well. Often I don't need all of the baggage that comes along with getopt(), just a simple parsing of argv.
Well that's a nice complicated program that violates the premise of the assignments and the teacher would never believe is mine anyway........ : ) : )
Wow. When you described yourself as a "champion puzzle solver", clearly you didn't mean as a programmer. Otherwise you'd be able to see that scudzilla's code is a test framework wrapped around the same algorithm you've been claiming doesn't produce the correct result.
distance
is the name of a function in the standard library, use it for something else at your own risk.
Check your spelling and choice of operators as well.
But just for fun-- run it a few times with different combinations and see what happens.
There are only 4! permutations. It's trivial to test this algorithm rigorously by hand.
Paragraph 15.3.15 of the standard: "The currently handled exception is rethrown if control reaches the end of a handler of the function-try-block of a constructor or destructor."
Try posting in the Hardware & Software category with appropriate tags. That's the "wave of the future" as far as forums and categories go.
Do people use tools that have FTP built in, or another piece of software for getting the files up to the server?
It's largely personal or based on choices made by the company. I use NetBeans as the IDE and FileZilla to handle FTP stuff. Dani uses Zend Studio, if I recall correctly.
Design and code a program in c that converts time in seconds to hours, minutes and seconds and display the results.
I'm done, but I don't have your teacher's email so that I can turn it in for a grade. Could you post that, please?
If you're talking about the PM notification where your private messages link turns yellow, there's not presently a way to turn it off. Further, there's an item on my bug list about that notification not being entirely accurate in all cases, but it's low priority since it doesn't happen often (in my experience at least).
If you're talking about some sort of popup dialog, I have no idea what you're talking about. ;)
It's not obvious that the check is a button or what it does. I suspect very few people have bothered to click on it.
the 2 things i am talking about are undefined and implementaion dependent. can you explain it with one more example like above ?
An example of implementation-defined would be support of void main(), or the oft supported envp parameter to main():
/*
Implementation-defined:
* void return from main()
* envp parameter
*/
void main(int argc, char *argv[], char *envp[])
{
}
If the compiler supports both of these, the above code is perfectly legal, but not portable. Further, the compiler's documentation must explicitly state support of these options or the compiler vendor must be able to adequately answer questions about such support. That's what I meant by "document".
A classic example of undefined behavior is the modification of an object multiple times between sequence points:
i = ++i + 1; /* Undefined */
This is wrong because i
is modified twice (once from the increment operator and once from the assignment operator) before the semicolon sequence point. The compiler vendor not only doesn't need to document the behavior when that statement is executed, it doesn't even need to choose a single behavior. In other words, you could run the same program twice and get two completely different results. The only solution is to break up the expression into two statements:
++i;
i = i + 1;
it is very good to see something which you are not able to answer correctly. :p
There's far too much information to memorize at …
undefined and implementaion dependent, both are not defined by C standard ?
Undefined means all bets are off, the program could do anything and has no restrictions, nor does it have to behave predictably. Implementation-defined means the compiler must choose a predictable behavior and document it, even if the standard doesn't provide options on what the behavior might be.
Further, unspecified means that the compiler must choose a predictable behavior but doesn't need to document it.
i have read somewhere that malloc may use sbrk() in which when we pass 0
sbrk() is a Unix-ism. Talking about portability while also depending on a specific underlying implementation is silly.
can you please give one more example to exemplify the difference between these 2 things ?
I'm not sure I understand what you want to see. Which 2 things need further example?
rather than needing multiple people in both permanent and contract positions, actually they aren't recruiting anyone at the moment.
Was this a large corporation? That would still be sad, but a bit more understandable than a smaller company.
I was asked this in an interview today:
Q: malloc(0); /* What does it do? */
It's a great question because it covers a subtlety in the standard and a condition that not many people will consider. Unfortunately, I wasn't 100% confident that I remembered what the standard said about it. With full understanding that I brought the question on myself by arrogantly describing myself as an expert in C, I gave my answer as follows: "A valid pointer will be returned, but that pointer cannot be dereferenced."
My answer was wrong. The interviewer said that the result was undefined behavior, which seemed slightly off to me at the time though I didn't challenge him on a nuance I wasn't assured of. As it turns out, my answer was partially correct, though in being partially correct it was still wrong. However, the interviewer wasn't correct either. The standard states the condition of a zero size request as follows:
"If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object."
Note that implementation-defined is very different from undefined. Undefined means that the very act of calling malloc(0)
invokes undefined behavior and as a result makes the entire program henceforth undefined as well. Implementation-defined means that malloc(0)
is legal and doesn't affect the legality of the rest of the …
An object is an instance but an instance isn't necessarily an object. They're both concrete entities based on a reference type or value type blueprint, but a value type instance should not be described as an object unless you box it.
brother, these aren't my homework problems.these are the questions which are asked in last interview. i couldnt code for these questions. so i posted these questions here. so that someone will comment the code.
"These aren't homework questions, they're just questions I was given to do that I want other people to answer for me."
Sorry dude, but around here that falls under the category of homework. Do your own work. We'll help if you get stumped, but we won't do it for you.
I'd also wager that the majority of the traffic drop was spammers using vBulletin tools. But since you keep asking about the traffic drop, Dani, I'm guessing you have a way of rejecting that theory?
I don't know anything in programming,so how do i start.
Buy a book on C# and read it. Seriously, you'll start learning by reading about the topic. If you don't know anything about acquiring a book and reading it, you should probably address that lack before learning to program.
Install Visual Studio Express, buy a book on C# and read it.
So I did some investigation, and our community activity took a DRAMATIC 30% hit the day that we switched over from vBulletin to our new proprietary platform, and never recovered since, despite traffic levels.
Out of curiosity, are you accounting for the spammers that were overwhelming us prior to the move being immediately reduced to 0% when the new system went live? If 30% of our traffic was 90+% spammers, I'm okay with the reduction.
and it is defined in a package called namespace std;
this is why we use namespace in every program
Everything was fine up to the quoted part. There's no "package" called namespace std, it's a logical grouping of all names in the standard library, not some physical module that defines things. In fact, you'll find that in the standard headers the declarations are also wrapped in the std namespace.
can you please notify me that whether i will get my a/c back or not
Sorry, but that account has been deleted and it's been stated multiple times that the process is irreversible. If there was any question about whether you wanted it back, you shouldn't have deleted it.
Good luck, have fun!
number
is a local variable whose lifetime ends when the constructor terminates. What do you suspect happens when the lifetime of the reference exceeds the lifetime of the referred?
Please read our rules concerning homework and proof of effort.
If I requested 8 bytes of memory, I wouldn't go and try to stick 16 bytes into the block I was just given, so what purpose does it have?
Once again, malloc() is required to align for any type. Just because you requested 8 bytes doesn't negate that requirement. That's not to say malloc() couldn't interpret the requested size and shrinkwrap the alignment accordingly, but the standards committee clearly chose not to go that route.
However, note that C11 (the latest standard) added aligned_alloc(), which supports specifying the alignment you want for a specific object rather than the maximally portable alignment.
Not sure why though, yet...
malloc() is required to give you a block with suitable alignment for any type. That's why it can return a pointer to void which you can then assign to any object pointer type. On your system aligning to the largest scalar type just happens to be the best (hopefully) way to meet that requirement.
I saw this one coming as soon as Dani gave members the ability to delete their account.
They got the power what they wanted, now they have to deal with the responsibility. I find myself lacking any sympathy at all, especially given how hard we make it to delete an account and how many "this is irreversible" notices they have to click through to make it happen.
It's parenthesized like this:
int m = (i++ || (++j && k--));
But || is still a left to right short circuiting operator, so i++
is evaluated first. If it evaluates to true, (++j && k--)
doesn't get evaluated. But if i++
evaluates to false, the right hand side of the OR expression is the final result of the AND expression. In other words:
if (i++)
{
m = 1;
}
else
{
m = (++j && k--);
}
but what would be the reason for anyone to have multiple accounts?
Well, from a technical standpoint I have my main account and a mortal user account for testing purposes. But it's obvious and not intended to be hidden: deceptikon_test. That way my admin permissions won't get in the way when testing a feature or bug.
But I'm sure that's not what you were asking. Why would someone have multiple accounts and actually use them independently, or even attempt to hide that they're powered by the same person? Three reasons come to mind immediately:
you have made diplomatic answer. if i try to fake it, then don't u think it will be good wheni start with basic solution and then pretend that i am approachinga good answer (which i already know) ?
Okay, I'll drop the diplomacy. If I discovered you doing something like this I'd end the interview immediately and tell you to piss off. Known liars get a no hire vote from me 100% of the time.
You should cultivate intellectual honesty. That'll win you more points than giving a good answer.
secondly, what will you say about this type of question. like i am giving interview for RBS or say AMAZON, they ask me "what if you get an offer from google after joining here ?" . it is really a very difficult question to answer.
I don't think that's a difficult question at all. Depending on your goals, be honest. Take NDA and non-compete agreements into consideration as well. If you'd rather work at Google, RBS or Amazon shouldn't be offended if your options change after you're hired. They may not like it, but they shouldn't fault you for keeping your options open and seeking the best possible job for your goals.
Keep in mind that an interview goes both ways. You're interviewing the company just like they're interviewing you. If they react poorly to an honest answer, that's indicative of a cultural mismatch. Despite all of the resources on how to nail the interview suggesting …
hashing the strings will i think scan the string atleast once. right ?
Yes.
While Daniweb has no rules against creating multiple accounts, this pattern strongly suggests spammer behavior. We're watching these folks closely.
Because there's no overloaded operator>> that does this for you. It's simple enough to write, though you could just as easily reverse the operation and dump cin into Mystr:
Mystr << cin.rdbuf();
That's probably why the overloaded operator doesn't exist, it's unnecessary.
can you tell me in context of C++ or C ?
unordered_map<string, int> freq;
string line;
// O(mn) complexity
while (getline(in, line))
{
++freq[line];
}
// O(n) complexity
for (auto x : freq)
{
if (x.second == 1)
{
cout << x.first << '\n';
}
}
i mean are you talking about this :
map<string,int> m;
Yes, that's a suitable option for implementing a frequency table. Though building a frequency table based on a balanced tree is O(nlogn).
in this map, it is red-black tree and it is logn complexity.
Search in a red black tree is O(logn).
then why O(m) is there with that, because in hash map we hash the strings in O(1).
Search in a hash map is amortized O(1). Did you think hashing strings of unknown length is an O(1) operation? ;) The O(m) part of the equation is to account for the management of your string data: copies, comparisons, etc... If you were working with integers or fixed length strings then that would all be constant time, but last I checked, URLs weren't fixed length.