6,741 Posted Topics
Re: ... Well, I'm glad you found your problem. | |
Re: What you've posted is not C. Please elaborate on any special libraries or preprocessors you're using. | |
Re: >The problem is that it appears to be working. Welcome to the world of C. Just because it appears to work doesn't mean it's guaranteed to continue working. >Will pointing to the first element of an array stop the >memory from being unallocated (or whatever)? No. The only reason it … | |
Re: Conceptually, calloc works like this: [code=c] void *calloc ( size_t n, size_t size ) { void *mem = malloc ( n * size ); memset ( mem, 0, n * size ); return mem; } [/code] | |
Re: >Just need to know what compiling actually does?? The 10,000 foot view is that a compiler takes one language and converts it into another. An assembler in particular takes assembly language code and turns it into machine code. | |
Re: >why would it have gone into an error state? end-of-file counts as an error state in this case. | |
Re: >What next should I go for c# or java? Conceptually they're both largely the same. I'd recommend learning a completely different language from what you're used to, like Haskell or one of the Lisps. You'll get more out of it than learning yet another C derivative. | |
Re: If you keep bumping your thread unnecessarily, I'll close it. Be patient and if someone wants to help, they'll help. | |
Re: Hasn't The Dude already been featured as a member of the month? | |
Re: >And show some freakin effort! >Read your text book!! >I mean please at least TRY. If it's simply a matter of being vague, there's no point in biting heads off when you could just as easily ask for more information, like "what have you tried so far?" or "what are … | |
Re: >Use fflush(stdin) Bad advice. fflush only has defined behavior for output streams. Passing an input stream is a one-way ticket to a broken program. | |
Re: >However, having multiple exit points for a function makes it difficult to maintain. Forcing a single exit point where it doesn't make sense also makes the function difficult to maintain due to added unnatural complexity. >There is a greater chance that you'll forget to do the clean ups >(which will … | |
Re: >How does this cheating thing works when you have an actual job? Tell me, I'm curious.. Cheating when the goal of an assignment is to learn only hurts yourself. "Cheating" when the goal is to get a job done helps productivity, though not necessarily quality. | |
Re: >I just made a script that when i give a password, it destroys the >whole site, delete every file. is that enough??? what else can i >do to make sure I get paid. I wouldn't recommend that strategy. You're more likely to get arrested than paid. | |
Re: Instead of declaring the buffer locally, pass it to your getcurrentdate function. That way you don't have to worry about returning it: [code=c] #include <sys/time.h> #include <time.h> #include <stdlib.h> #include <stdio.h> char getcurrentdate(char buffer[]); int main(void) { char currentdate[30]; getcurrentdate(currentdate); printf("date is%s",currentdate); } char getcurrentdate(char buffer[]) { struct timeval tv; … | |
Re: There's not enough code to reproduce your error. Please write a complete sample program that has the error and then post it. >double q[] = norm(pst, y); This in particular is wrong. norm returns a double, not an array of double. | |
Re: A lot of words for not a lot of information. :icon_rolleyes: Perhaps you can explain what you mean exactly by "The programming is not termination with a keystroke". I daresay that you're not starting off the right way. Your code is horrible, your choice of compiler is probably not going … | |
Re: For the sake of getting you doing the right thing, I'll suggest a mnemonic. Conditional and loop statements can be treated syntactically the same as functions. The "tag" isn't terminated with a semicolon, and the body is surrounded with braces: [code=cplusplus] void reverse(string& st) { int i; int j = … ![]() | |
Re: After you close the file for the first time, the eofbit is still set. You need to clear it with [ICODE]fis.clear();[/ICODE] before the second loop will work. Apparently your Linux compiler chose to clear the state either on close or open. | |
Re: >Can someone please give his opinion about the free >available borland compiler, is it good to use nowadays? I assume you're talking about the 5.5 command line compiler, which is good, but it's starting to get dated. The latest and greatest free compiler is a part of Borland's [URL="http://www.turboexplorer.com/cpp"]Turbo C++ … | |
Re: >Well I couldn't really make out if you people were against >usage of system library function here in this context. By my reading, death_oclock isn't sure, and ArkM hasn't stated a preference. >If yes could you state the reason...? In this case, system is still risky, but no more risky … | |
Re: There's probably not a tutorial because there's nothing to it. Brute force searching is the dumbest, easiest (and often most inefficient) way you can think of to get the correct answer. In the case of a graph, you'd probably end up doing a recursive traversal of all nodes. Why don't … | |
Re: >is there something wrong wid this code? Yes. >void main(int argv,char * argc[]) main returns an int. >num1=(int)argc[1]; >num2=(int)argc[2]; For starters, argc is the size of argv. argv is the array of strings. Next, you're expecting a cast to convert "123" to 123, which is not how things work. What … | |
Re: >i can't understand the increment and decrement of pointer variable. Pointers are an abstraction. Think of it like this: a pointer points to a thing. When you increment a pointer, you tell it to point to the next thing. When you decrement a pointer, it points to the previous thing. … | |
Re: >as these both topics are vast and very time consuming Perhaps if you're trying to get a PhD or something in one of them. But as a practicing programmer, you can easily learn enough about both to improve yourself. Learning one topic to the exclusion of equally important topics is … | |
Re: My crystal ball says that you're trying to make it a member function when it should be a non-member. | |
Re: >Right? *crosses fingers* Change "strings" to "things", "structs" to "lists", and you've got it. I'll also direct you to a more detailed reference: [url]http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx[/url] [url]http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_hashtable.aspx[/url] | |
Re: Not enough information, could you elaborate on the problem? | |
Re: >can u tell me some links which will be useful to me in creating a compiler...... Maybe if you gave us the actual requirements for your assignment. You're confusing a lot of people here by saying you need to write a C compiler in two months, but it only needs … | |
Re: C# and VB.NET (probably what your friend meant by VisualBasic) are essentially the same language with a different look and feel. Pick which one you're more comfortable with and go with it. | |
Re: Unless you care about working out the math for the diminishing size of the inner loop (in which case you shouldn't have any problem with it), the complexity is quadratic because that's the upper bound. | |
Re: >I am not the best at it at all by any means Nobody started out knowing what to do and how to do it. We all needed to learn how to solve problems effectively and efficiently. Unfortunately, there's really no shortcut. Mistakes, as they say, become experience. >Is this a … | |
Re: >I've been told that Information Technology requires less math then a CS degree. Maybe to get the degree (I wouldn't know, I don't have a degree), but the kinds of jobs you'd get with either a CS or IT degree [I]will[/I] require math. Consider yourself warned. >What worries me though … | |
Re: [quote] ok, i'm somewhat of a noob to c++ programming and i'm completly lost in my class as of now, i mean i understand the concepts(somewhat) but actually writting my own code is really confusing me, i dont want anyone to give me the answer, but if someone could guide … | |
Re: >Why would you ever use a pointer to a pointer? Well, you have to if you ever want to take advantage of command line arguments. In C++ a reference to a pointer would be better if you just need a pointer that can be modified in another function, but pointers … | |
Re: >This compiles Probably not cleanly. Check your warnings. >Can someone explain me why does this happen Aside from the fact that you're trying to access a run-time value at preprocessing time (ie. long before it exists)? | |
Re: This is typically where polymorphism is used, but without an idea of the design of your objects, I can't really offer much more than that hint. | |
Re: When you overload the () operator, it's used as if it were a function call operator and nothing more: [code=cplusplus] #include <iostream> struct foo { void operator()() { std::cout<<"FOO!\n"; } }; int main() { foo bar; bar(); } [/code] If that's not what you want, you're SOL. | |
Re: >how much memory does the following take? >const int a[]; >answer: I don't think it is defined. It's quite well defined. You're referring to a function parameter, which (due to the conversion of arrays to pointers) is equivalent to [ICODE]const int *a[/ICODE]. >+ Outside class: It outputs 3 (correct) >+ … | |
Re: >but I have a dial up connection and dad doesn't like me tying up the phone lines What the hell are you talking about? It's no faster to create a new thread than it is to reply to an existing one. That's a lame excuse for being lazy. >what should … | |
Re: >I think it should be in the rules, that posting to old threads is a no no. Dani has stated many times that necrobumping is allowed as long as the new post is on topic and can be viewed as a continuation of the discussion. A "me too!" post (where … | |
Re: >Because I needed 0. Adding zero does nothing. Do you remember your elementary school arithmetic? 1 + 0 = 1 2 + 0 = 2 3 + 0 = 3 ... N + 0 = N | |
Re: A two dimensional array is not a compatible type with an array of pointers. When you pass a multi-dimensional array to a function, the first dimension is converted to a pointer: int[2] becomes int* int[2][4] becomes int(*)[4] int[2][4][6] becomes int(*)[4][6] To properly pass D_2, transpose_mat has to expect either [ICODE]double … | |
Re: >Can somebody explain why in the code below, when i use free(), it crashes. That's easy. You corrupted the memory and the dynamic memory manager is choking because the corruption removed something it expects to see. A common situation that causes this problem is failing to allocate enough memory for … | |
Re: >Say function A() returns a char* which points to a string.. obviously Not obviously. While char* usually denotes a C-style string, there's nothing stopping you from returning a pointer to char where a null character isn't used as a terminator. Keep in mind that C-style strings are defined by the … | |
Re: >A friend convinced me to store a vector of pointers in my class What was your friend's reason? Why did you have to be convinced? This sounds a lot like you went against your gut feeling and now you're regretting it. >This just seems like a horrible horrible idea. It's … | |
Re: Since your writing skills are so poor, I'm not sure you'll be able to read any of the "gud" ebooks. But on the assumption that you're simply lazy rather than stupid, try [url=http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html]this one[/url]. Also, there's no such language as C/C++. There's C and there's C++, but no C/C++. | |
Re: >it possible to build your own operator with your own definition and your own symbol for every type? Yes, it's called a member function with an informative name. But if you're thinking about creating something like ** for exponentiation or ^^ for a logical exclusive OR, you're out of luck. … |
The End.