6,741 Posted Topics
Re: [QUOTE]Post your error code please.[/QUOTE] I agree. The code is more or less fine. The [ICODE]using namespace std[/ICODE] statement at the top of the date.h header could cause a problem, but that should have nothing to do with accessing public vs. private members. [QUOTE=Ketsuekiame]You're trying to access a private variable … | |
Re: Unless you specifically pause execution or ask for input at the end of the program, the window should close on its own. However, some IDEs pause the window for you as a development convenience. I suspect you shouldn't need to worry about it, but how are you running the program? | |
Re: [QUOTE]I know it has something to do with my default constructor[/QUOTE] You're correct. That "something" is the fact that you don't have a default constructor. A default constructor is only generated for you if there are no other user-defined constructors in the class. | |
Re: [QUOTE]pointers are the most difficult topic in c language so don't take it easily[/QUOTE] Pointers are only the most difficult topic because people like you brainwash beginners into believing they're difficult. Pointers are in reality very simple. | |
Re: [QUOTE=camdaddy09]Its come to my attention that some members of this board do NOT regard the feelings of others as any importance at all when considering a reply.[/QUOTE] One doesn't garner respect simply by having a pulse. Respect is earned through proving that one is worthy of respect. [QUOTE]This is contradictory … | |
Re: I'm not familiar with Netezza, but if it's an external application with command line functionality, or an application that exposes an API, or a web service, you can certainly send input and retrieve output using pipes. However, that's a rather platform-specific solution, so it would be best if you gave … | |
Re: [QUOTE=jose jimenez] if you don't like the newline being included in fgets, then just remove it. [CODE]if (buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = '\0'[/CODE][/QUOTE] Close. There's no point in calling strlen twice, especially since strlen has guaranteed O(N) complexity (barring clever tricks in the implementation). It's just … | |
Re: [QUOTE]my_printf.c: In function `[B][U]print_str[/U][/B]':[/QUOTE] I suspect you're not posting all of the relevant code. print_str isn't mentioned except in the error. | |
Re: You don't have a main function... | |
Re: You clearly didn't do much searching before posting here, because MSDN has a knowledgebase article on this exact subject. | |
Re: Is CEA_Process forward declared prior to CEA_Disk_lister? Because as posted it won't exist and the definition of CEA_Disk_lister will fail. | |
Re: Site navigation feels clunky now. I'm not sure what use cases you were using to design the site, but it's definitely more tedious to get around, in my opinion. I think it's this feeling of rough navigation that makes the whole site seem "bigger" and "harder to read". I'm not … | |
Re: I suspect for people with kids it'll be when the kids were born. For married people, it's when they were married. For single people it'll be something selfish and silly, or the day they were divorced. ;) That should cover just about everyone. Do I win the thread? ![]() | |
![]() | Re: Can you give an example of how your headers look instead of just which includes the other? |
Re: [QUOTE=gear26926;1222654]The result for the given code snippet is i = -2, j = 3, k = 0, m = 1 Cud u please explain how u get this result?[/QUOTE] i is incremented, j is incremented, and both are not 0 (true), so k is not incremented. You're mixing two things … | |
Re: The error is pretty detailed. Somewhere in the damagecalculation function you're trying to assign an integer to a string object. Check the function call to and verify your types. | |
Re: Sorry anuragcoder, I'm going to ignore you now. Hopefully you'll realize that flooding the forum with bad questions is counterproductive and start concentrating on quality rather than quantity. In the meantime, here's some [URL="http://catb.org/~esr/faqs/smart-questions.html"]light reading[/URL] for you. | |
Re: [QUOTE]undefined symbol _main in module c0.ASM[/QUOTE] A complete C program requires an entry point. The entry point is called main; you may have heard of it. [QUOTE]where to put the printf("Enter values: ");?[/QUOTE] The main function that you're going to add. [QUOTE]in the scanf, what variable i would use? is … | |
Re: [QUOTE][CODE]int main();[/CODE][/QUOTE] Are you sure you wanted a semicolon there? | |
Re: Do it the same way you'd do it in Windows (open the file in binary mode and use the read/write functions). This can be done with standard code, though the contents of the file will not be portable due to implementation-defined padding between structure members. So your file can't be … | |
Re: [QUOTE]implentation of m-ary tree in C[/QUOTE] If you understand the concept then an implementation isn't terribly difficult with a little effort on your part. So go do your own homework. We won't bail you out. kthxbye. [QUOTE]any simple example?[/QUOTE] No. In my experience, people asking for "simple" examples of something … | |
Re: [QUOTE]The packages are different under XP and linux?[/QUOTE] No. Your code under Windows was benefiting from internal includes. That is, standard headers themselves include other standard headers, which means somewhere in <iostream>, for example, <cstdlib> was included. atof is declared in <cstdlib>, so your calls magically worked. It's best to … | |
Re: [QUOTE]I wondered if like vector<int> I could do vector<char[20]> but it doesn't seem to work, your ideas?[/QUOTE] No. Arrays don't meet the basic requirements of types suitable for storage in a vector (ex. assignment isn't allowed on arrays). You could use a dynamic C-style string and store char* in your … | |
Re: [QUOTE]eisodos1[i]=getchar(); (1) (1) assignment makes pointer from integer without a cast (I dont even know whats a cast)[/QUOTE] eisodos1 is an array of pointers to char. getchar returns an integer. There's obviously a type mismatch here. You're trying to assign an integer to a pointer. [QUOTE]e=eisodos1[i]; (2) (2) assignment makes … | |
Re: Are you trying to compare the vectors as a whole? As in [ICODE]if (buy <= ask)[/ICODE]? | |
Re: vector<int> is a type, but those member functions are expecting an actual object of the type. | |
Re: Your Point class doesn't have a copy constructor. Passing objects of that class around by value is an exceptionally bad idea since the data members are dynamically allocated. Default copy construction won't work in this case. | |
Re: fputc writes a single character to the specified string. If you want to convert an integer to a string and then write it to your file, fprintf would be the easiest: [code] fprintf(fp, "%d\t%s\n", temp.number, temp.description); [/code] | |
Re: [QUOTE=Martje;1220975]when you have 2 pointers pointing at the same address isn't it the-same as a reference pointer(*&)?[/QUOTE] No, it's not. What makes you think so? | |
Re: >if you wanna do it... that would be awesome Sorry, but that's not going to happen. We're not a homework service. >Can anyone help me code this?? No, but we can help you understand it and help you correct and problems in the code you write as well as suggest … | |
Re: [QUOTE]I am not sure what EOF is on the keyboard or what triggers it.[/QUOTE] If you're on Windows, the Ctrl+Z key combination sill signal end-of-file and cause getchar to return the EOF flag rather than extract a character from the stream. On Unix/Linux, the key combination is Ctrl+D. | |
Re: You don't need an array, this can be done by streaming the numbers to the output file directly using a merge algorithm. The merge algorithm is straightforward, and I'll encourage you to see what you can come up with on your own. However, merging is a common task, so you'll … | |
Re: Did it not occur to you that you can upgrade to a more modern compiler? You should be aware that C is no longer the same language it was when Turbo C came out. Not to mention compilers in general have improved [i]drastically[/i] in the last twenty years. | |
Re: [QUOTE=camdaddy09;1219697]why is scanf() unreliable and unwanted?[/QUOTE] scanf can be reliable when used correctly, but it's typically unwanted for string input because achieving reliability in that case is more difficult than simply using a more appropriate function. For example, here is fgets simulated using fscanf: [code] char *myfgets(char *dst, size_t limit, … | |
Re: [QUOTE=merse;1219090]But I dont want to use string manipulation, if it is possible, because its very simple, and I want to read numbers,[/QUOTE] What's the format of your file? | |
Re: Example to get you started: [code] #include <ctime> #include <iomanip> #include <iostream> using namespace std; void wait(int seconds) { clock_t endwait; endwait = clock() + seconds * CLOCKS_PER_SEC; while (clock() < endwait) {} } int main() { const int dots = 3; const int n = 5; cout<<"LOADING"; for (int … | |
Re: [QUOTE]how can we catch this end of file to signify end of program?[/QUOTE] On Windows you can use the Ctrl+Z key combination to signal end-of-file. On POSIX systems you can use Ctrl+D. In code, it's pretty much the same pattern as with files: [code] int num; // Read numbers until … | |
Re: [B]>So have your routine choose either 0 or 1 (so use rand() % 2) >and then select the appropriate number with an if statement.[/B] [ICODE]rand() % 2[/ICODE] is especially risky when it comes to getting the same result every time (for reasons I'm not interested in detailing at the moment). … | |
Re: If you want to leverage polymorphism you should be using an array of pointers to the base class. The array itself doesn't need to be passed by reference because it's already passed as a pointer to the first element (simulated pass-by-reference). | |
Re: [B]>vector<int> ints; // dynamic array of ints[/B] No, it's a vector of int. I very much doubt that's what the OP was thinking of when saying "dynamic array". :icon_rolleyes: [B]>char* str; >while (cin >> str) ints.push_back(atoi(str)); // adding[/B] Really? Shall we explore the fact that this is probably the most … | |
Re: >I would be highly grateful if u give me the code I'm sure you would. Do your own work, it's much more rewarding. | |
Re: [code] #include <algorithm> #include <cctype> #include <iostream> #include <string> using namespace std; int lower_case ( int c ) { return tolower ( c ); } int main() { string s = "THIS IS A TEST"; transform ( s.begin(), s.end(), s.begin(), lower_case ); cout<< s <<endl; } [/code] Before you ask, … | |
Re: [B]>i like all of u[/B] I believe I can cure you of that. [B]>plz if anyone knows plz help me[/B] Dude, slow down and take the time to compose a [URL="http://catb.org/~esr/faqs/smart-questions.html#writewell"]coherent post[/URL]. This isn't a chat room. You've got all the time in the world to make your posts presentable … | |
Re: [B]>Shouldn't the terminology be taught early on >with stuff like cout, variables and if statements?[/B] If only it were that easy. For example: super/sub, parent/child, base/derived. They all mean the same thing. Good luck teaching which one is appropriate in which situation without completely confusing the student. The problem isn't … | |
Re: [B]>I just can't seem to compile it. >Will someone please give me some suggestions?[/B] I'd suggest reading the errors, tracing the source of the problem, and applying a fix to the code. What were you wanting us to do? Debug your code and give you the working program? Do you … | |
Re: [B]>and why we are checking this condition ?[/B] [ICODE]if(num[i]>num[j]) [/ICODE] Why would you want to swap items that are already in the correct order? | |
Re: [B]>Could someone give me some advice?[/B] Not without seeing any code, no. Your problem appears to be a runtime error more than confusion about true and false. [B]>TRUE and FALSE are defined, as 1 and 0 respectively, in stdbool.h for C99.[/B] They're both lower case, actually: [code] #define bool _Bool … | |
Re: scanf fails if it can't convert the incoming stream into a valid number, and it doesn't extract the bad characters. So unless you extract them yourself you'll get an infinite loop as scanf continues to fail on the same stuff. [code] // Unsafe; risks an infinite loop while (scanf("%d", &x) … | |
Re: [B]>What's the prize??[/B] The prize is full marks to the OP if he can convince some rube to help him cheat on his homework. |
The End.