6,741 Posted Topics
Re: Yes, it's possible. The destination array needs to be large enough to hold the replacement, and the process is rather manual. You'll shift everything to the right of the matching character to make a hole, then overwrite what was in the hole with the new data: [code] # Find 'e' … | |
Re: [QUOTE] In terms of why, my only possible explanation is that there is a different implementation for operator+ and operator+=???[/QUOTE] Consider that operator+= returns a reference to the current object while operator+ returns a new string object. | |
| |
Re: [QUOTE]What is the best way to design a program?[/QUOTE] Opinions will vary, and methodologies can be mutually exclusive (ie top-down vs bottom-up design). Design is actually a pretty deep subject. [QUOTE]Are there any specific steps i should take when designing a program?[/QUOTE] In small programs, I'll just wing it and … | |
| |
Re: This is a different matter entirely. The question you linked to was specifically about not printing a line break after hitting the Enter/Return key. Your requirement is merely not to print a newline character, which you're already doing. | |
Re: You could probably simplify the file operations. What is this program supposed to do? | |
Re: I have no idea what you're trying to say (what the hell is "return a book" supposed to mean?), but the file failed to open when fopen returns NULL, not the other way around. Your if statement is reversed. | |
Re: You're a [I]second[/I] year CIS student and don't even know where to start? I weep for this generation of programmers. How about starting with one account class and working out the credit/debit actions? From there you can add more accounts, set up branches, etc... This project practically slaps you in … | |
Re: addinf and address are both pointers to structures, so you'd need to dereference the pointer before accessing members: [code] (*(*stud.addinf).address).housenumb = 123; [/code] Alternatively, the arrow operator does this for you in a much more convenient manner: [code] stud.addinf->address->housenumb = 123; [/code] Note that those pointers must point to something … | |
Re: Will an example help? [code] #include <stdio.h> #include <string.h> void dump_file(FILE *in, FILE *out) { int byte; while ((byte = getc(in)) != EOF) putc(byte, out); } int main(void) { /* Use binary if you want to seek arbitrarily */ FILE *in = fopen("test.txt", "rb"); if (in != NULL) { long … | |
Re: [QUOTE]There is at least one person(me) who has not even the faintest idea of what it could be?[/QUOTE] It's an MP3 player. I've been considering buying one for the gym. | |
Re: [QUOTE]why is it allowed to store chars in ints.[/QUOTE] [ICODE]char[/ICODE] is an integer type, just with a smaller range than [ICODE]int[/ICODE]. It makes sense that since [ICODE]int[/ICODE] can hold every value [ICODE]char[/ICODE] can, a widening conversion from [ICODE]char[/ICODE] to [ICODE]int [/ICODE]should be possible. [quote]also if i put getchar in a … | |
Re: Read characters until a newline or EOF is reached: [code] int ch; do ch = getchar(); while (ch != '\n' && ch != EOF); [/code] This is the only portable method, but it also has a downside of blocking for input if the stream is already empty when the loop … | |
Re: [code] int byte; while ((byte = getc(stream)) != EOF) { /* ... */ } [/code] | |
Re: Static data members [URL="http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/cplr038.htm"]still need to be defined[/URL]. | |
Re: [QUOTE]I don't believe the for each (idiom?) exists in C++/CLI.[/QUOTE] It does: [code] #include <iostream> #include <vector> int main() { std::vector<int> v; for (int i = 0; i < 10; i++) v.push_back(i); // C++/CLI foreach for each (int x in v) std::cout<< x <<'\n'; } [/code] | |
Re: Whoa, [URL="http://www.daniweb.com/forums/thread335181.html"]deja vu[/URL]. | |
Re: Something along these lines: [code] import java.util.*; class Main { public void display_menu() { System.out.println ( "1) Option 1\n2) Option 2\n3) Option 3" ); System.out.print ( "Selection: " ); } public Main() { Scanner in = new Scanner ( System.in ); display_menu(); switch ( in.nextInt() ) { case 1: System.out.println … | |
Re: The file names are irrelevant. What is you [I]class[/I] called? | |
Re: You didn't post enough code for me to be sure, but from the error I'd guess filePath is a data member and you're doing something like this: [code] ref class Form1 { String^ filePath = this->listView1->CheckedItems[0]->SubItems[2]->Text; // ... }; [/code] C++ doesn't work like that though, you want to do … | |
Re: [URL="http://en.wikipedia.org/wiki/Inter-process_communication"]Use IPC techniques[/URL]. In particular, a pipe would be best suited. Of course you're totally over-engineering the problem and making it ten times harder than it should be. :icon_rolleyes: | |
Re: What does your archive file format look like? A simple format would consist of records like so: [code] struct record { size_t size; unsigned char *bytes; }; void write_record(FILE *out, struct record *rec) { fwrite(rec->size, sizeof rec->size, 1, out); fwrite(rec->bytes, 1, rec->size, out); } int read_record(FILE *in, struct record *rec) … | |
Re: That code shouldn't compile at all, much less output the wrong value. Try this program and see if you get the same erroneous output: [code] #include <stdio.h> int main(void) { int a = 10, b; b = (a >= 5) ? 100 : 200; printf("%d\n", b); return 0; } [/code] | |
Re: [QUOTE]What I 1as wondering is this a gd way to get experience with the intention of obtaining a job in software development when I leave uni?[/QUOTE] Work on a project with public exposure so that you can use it in your portfolio. Open source projects are a fantastic option because … | |
Re: [B]>using namespace System[/B] Just add a semicolon and you should be solid: [code] using namespace System; [/code] [QUOTE]How do i do an internal class in C++?[/QUOTE] The private keyword at class level has the same semantics as internal in C#: [code] private ref class UserFeedback { public: static void Error(Exception^ … | |
Re: difftime returns the difference in seconds: [code] #include <stdio.h> #include <time.h> time_t get_date(int year, int month, int day) { time_t start = time(NULL); struct tm *date = localtime(&start); date->tm_year = year - 1900; date->tm_mon = month - 1; date->tm_mday = day; return mktime(date); } int main(void) { time_t bday = … | |
Re: I wouldn't recommend recursion for this problem, but you also didn't ask a question. You just posted your requirements, which strongly suggests that by "help" you really mean "do it for me". :icon_rolleyes: | |
Re: [QUOTE]I was thinking a pointer or something along those lines any idea guys?[/QUOTE] A pointer to what? You clearly need to know how to send an email, and you need to be able to find the email address of any restaurant in the chain. Sending emails is straightforward (if not … | |
Re: Do it your damn self. If you have a specific problem with your code, we'll help, but don't expect anyone to do everything for you. | |
Re: [QUOTE]What I would like to do however is code it so the user can enter multiple numbers until the user enters 40 and then display the histogram accordingly[/QUOTE] You have the basic idea of building a histogram, so just throw that inside of a loop: [code] while (std::cin>> grade && … | |
Re: Turbo C is a 16-bit compiler, which essentially means that the actual range of int is [32,767, -32,768] (16 bits, two's complement). It simply can't handle 800000, but long can. The fix in your case is to change your code to use long instead of int. As a side note, … | |
Re: A forward declaration does nothing but introduce the name of a type into the current scope. Headers typically provide full declarations, which include member information as well as the type name. | |
Re: [QUOTE]Please tell me how can I make this application easily?[/QUOTE] Microsoft Access. | |
Re: I actually posted a code snippet the other day that implements a fast line search example. You still get the slowness, but only once when indexing the file. Subsequent searches are much faster. | |
Re: >Though you may be able to compile C code in Dev-C++. You can. You just need to be sure that the source file extension is .c instead of .cpp. | |
Re: Assuming your ints are 32-bit, FFFFFF01 exceeds INT_MAX. strtol should correctly return INT_MAX because the value passed in is out of range. While I'm sure you expected strtol to take a value with the sign bit set and produce a negative value, that's not how it works. The values are … | |
Re: The first error is that your code is littered with HTML and won't compile. | |
Re: [QUOTE]I don't think VS can do it.[/QUOTE] No conforming compiler will do it without an extension. Inline definitions must be provided in every translation unit, so it makes far more sense to place the definition in your class definition, or put an external definition in the header. Otherwise you'd need … | |
Re: [QUOTE]Is this right to say Heap is RAM and Stack is Pagefile(HardDrive)?[/QUOTE] No. Both are RAM-based and both can be swapped into virtual memory if they exceed limits. However, the stack size is not dynamic, so it's less likely to dip into virtual memory than the heap. You can set … | |
Re: [QUOTE]According to the book, it said "This is not guaranteed to remove the third element, even though that was intended. In most real-world STL implementations, it erases both the third and the sixth elements."[/QUOTE] Beware lack of context. Your quote is actually quite wrong when taken out of context, but … | |
Re: [CODE]for(i =0; i <= elgbotsections.size(); i++);[/CODE] You have a rogue semicolon here that should be removed, it's causing the loop to run to completion without doing anything, then when you try to access the vector, i is out of bounds. Also, it should be [iCODE]i < elgbotsections.size()[/iCODE]. You presently have … | |
| |
Re: Some of your function definitions have a rogue semicolon before the opening brace. Clearly you copy-pasted the declaration and forgot to remove the semicolon. | |
Re: Your thread class is somewhat confusing because it manages all threads. Compare that to something a bit more single-thread oriented where the calling application manages multiple thread objects: [code] #include <windows.h> namespace jsw { namespace threading { class auto_event { public: auto_event(): _event(CreateEvent(0, false, false, 0)) {} BOOL wait(DWORD timeout … | |
Re: What are the errors? Copy and paste them instead of paraphrasing, please. Also, how is Window2 defined? | |
Re: [QUOTE]rand()%2 is not guaranted to generate random number.[/QUOTE] rand is a pseudorandom number generator, it's [I]never[/I] guaranteed to be random. Your suggestion is really based on the history of rand, where implementations had a tendency to have very predictable low order bits. The division solution fixed the problem by using … | |
Re: [QUOTE]1. How is the code re-usable in OOP ?[/QUOTE] [URL="http://liberty.princeton.edu/Publications/tech03-01_oop.pdf"]Click me[/URL]. [QUOTE]2. How is OOP more secure than Procedural programming?[/QUOTE] OOP is neither less nor more secure than procedural programming. Anyone who told you otherwise was trying to sell OOP by bullshitting. [QUOTE]3. Compared to procedural programming how is OOP … |
The End.