6,741 Posted Topics

Member Avatar for vanalex

[QUOTE]Is it mandatory to use operator= overloading every time i write a copy constructor?[/QUOTE] Unless you're going to make operator= private, it's a good idea to include it as well as a copy constructor and a destructor. Because if you [i]need[/i] a copy constructor, more often than not you need …

Member Avatar for vanalex
0
152
Member Avatar for Jelte12345

[QUOTE]But when I run the release version it gives me an error after having run a while.[/QUOTE] Not only is your bug dependent on debug vs. release, it's also intermittent (as I understand from "having run a while"). How large is the code base? Are you able and willing to …

Member Avatar for Jelte12345
0
163
Member Avatar for fka

Without error handling: [code] char **exParam = malloc(n * sizeof exParam); char **exText = malloc(n * sizeof exText); for (i = 0; i < n; i++) { char *param = strtok(lines[i], "#"); char *text = strtok(NULL, "#"); exParam[i] = malloc(strlen(param) + 1); exText[i] = malloc(strlen(text) + 1); strcpy(exParam[i], param); strcpy(exText[i], …

Member Avatar for Narue
0
179
Member Avatar for mariko

Darth Vader became drastically less powerful due his injuries, which included loss of flesh. Since midichlorians have sadly been introduced into canon, it's probably safe to say that losing a limb [I]does[/I] decrease midichlorian count, which in turn makes a Jedi lose power.

Member Avatar for diafol
0
223
Member Avatar for richyvr

[ICODE]itk::Image<T, D>::Pointer[/ICODE] is a dependent type, meaning it depends on template parameters for the specific type definition. In these cases you need to specify that it's a type rather than an object: [code] template <class T,int D> typename itk::Image<T, D>::Pointer CreateITKImage(int *pnSize, double *pdSpacing = NULL) { // ... } …

Member Avatar for richyvr
0
138
Member Avatar for gth759k

Note that C++ doesn't use references for objects by default, so [iCODE]Vector campos;[/iCODE] in C++ is equivalent to [icode]Vector campos = new Vector();[/icode] in Java. With that in mind, it should be obvious that your Vector class doesn't have a default constructor even though you try to call one.

Member Avatar for gerard4143
0
3K
Member Avatar for tomtetlaw

[QUOTE]1. What is the purpose of using a DLL over a .lib or just a single .exe?[/QUOTE] Smaller executable size, smaller memory footprint, and easier update deployment of the library code (eg. the executable need not be recompiled). [QUOTE]2. What exactly (in VC++) does __declspec(dllimport) and __declspec(dllexport) do and where …

Member Avatar for tomtetlaw
0
94
Member Avatar for Mr_PoP

You're working with single characters rather than strings. Try changing the type of npcname and actid from char to std::string. Also note that the loop won't work too well with strings. You probably want to check all characters.

Member Avatar for Saith
0
79
Member Avatar for Don_k

Header files are only there for convenient access to type and function declarations, they don't (rather, shouldn't) contain definitions or any executable code. As such, it's often easier to lump everything in a single *.c file until you have a working draft, then break out the declarations into a header.

Member Avatar for Don_k
0
291
Member Avatar for fab2

[CODE]Why????[/CODE] It might make more sense if you convert to a while loop: [code] i = 1; while (i <= 20) { b = i * 30; printf("b é uguale a: %d = %d * 30\n\n",b, i); ++i; } [/code] i is always incremented after the body of the loop …

Member Avatar for fab2
0
115
Member Avatar for sobi07

Lazy much? Your code is fundamentally very C-like, so the conversion should be little more than changing couts to printfs, cins to scanfs, and using pointers instead of references. At a quick glance, those are the only changes necessary to compile as C.

Member Avatar for sobi07
0
111
Member Avatar for Mr_PoP

If you're replacing every instance of a single character with another single character, std::replace from <algorithm> is better suited than any of the std::string::replace overloads: [code] #include <algorithm> #include <iostream> #include <string> using namespace std; int main(void) { string test; test="this is a test"; replace(test.begin(), test.end(), ' ', '~'); cout …

Member Avatar for Mr_PoP
0
165
Member Avatar for Akill10

[QUOTE]How would you use this?[/QUOTE] It's less useful in C++ than C89, where all variables must be declared at the beginning of a block. Though unnamed blocks are useful if you want to force a shorter lifetime on resource intensive objects: [code] // Lots of code { ResourceIntensive ri(...); ri.do_stuff(); …

Member Avatar for Akill10
0
136
Member Avatar for aplh_ucsc

Take all of the declarations and put them in a header file: [code] void *newMalloc(size_t vol); void newFree(void *adPtr); void save(); void search(); void *findSpace(); void freelist(); [/code] Add any includes that are required by the declarations: [code] #include <stddef.h> // For size_t void *newMalloc(size_t vol); void newFree(void *adPtr); void …

Member Avatar for aplh_ucsc
1
128
Member Avatar for Narue

This is an example of using a binary index file to speed up random access of lines in a file. The file is indexed one time, where the position of the start of each line is stored in an index file. Subsequent requests for a get the position from the …

4
366
Member Avatar for Mst8kenId

[CODE]i was kind of hoping for the specific name of the algorithm they use[/CODE] You're not the first person to ask, and Apple hasn't been forthcoming, so it's a safe bet that they don't want you to know.

Member Avatar for Narue
0
121
Member Avatar for nhes2x

123 % 10 is 3. 123 % 100 is 23 23 / 10 is 2. 123 / 100 is 1. Extrapolate an algorithm from that.

Member Avatar for Narue
0
125
Member Avatar for ac.morgan

[QUOTE]Would it be okay if I asked for advice on different problems I am having with the calculator and how to program certain things on it without providing a code?[/QUOTE] Those kinds of questions are tricky to ask right. As long as you keep it on a conceptual level and …

Member Avatar for Narue
0
120
Member Avatar for abarnett

>but I'm not sure if that's right. Who cares? Try it and see if it works. This program is small enough that you can comfortably experiment. >I haven't actually wrote code for it yet, just trying to get an idea of where to start. You have an idea of where …

Member Avatar for kvprajapati
0
2K
Member Avatar for Gen.Asura

Could you perhaps ask a specific question? Right now it looks like you're asking for some charitable soul to do your homework.

Member Avatar for Gen.Asura
0
183
Member Avatar for arlir

guard_rec is an array, not a struct instance. You need to index into the array before any member access can be done: [code] /* Where i is a suitable index */ guard_rec[i].first_name [/code]

Member Avatar for gerard4143
0
153
Member Avatar for tomtetlaw

[QUOTE]Is it possible to have a pointer to something (say a string) that is on the hard disk?[/QUOTE] For a very liberal definition of "pointer", yes. But if you mean a C++ pointer type, no.

Member Avatar for Narue
0
119
Member Avatar for Shift_

[QUOTE]1) Base* ptr = new sub; Kinda confused about this - and also, how/why it is useful to have a base class pointer storing the adress of a sub class. Perhaps someone could clear this up for me?[/QUOTE] Generally, it's useful when you want to handle multiple related types (which …

Member Avatar for Suramachandran
0
134
Member Avatar for JOSheaIV

You can make a public globals class with public static fields representing the "global" variables. Not exactly a good design, but it works.

Member Avatar for JOSheaIV
0
112
Member Avatar for Benkyou

Start by getting a handle on socket programming: [url]http://beej.us/guide/bgnet/[/url]

Member Avatar for sree_ec
0
347
Member Avatar for judithSampathwa

For starters, you're not defining boundaries on the string, so you'll get false positives for an embedded match. Here's one from my personal library of regular expressions, it more or less rolls your two patterns up into one (but notice the boundary checks): [code] @"^\(?(?<NPA>[2-9]\d{2})(\)?)(-|.|\s)?(?<NXX3>[1-9]\d{2})(-|.|\s)?(?<NXX4>\d{4})$" [/code]

Member Avatar for Narue
0
433
Member Avatar for ambageo

I don't see how searching for a duplicate before insertion is problematic. Just traverse the list and if you get to the end, append a new node: [code] struct node *append_no_dup(struct node *head, struct node *new) { if (head== NULL) head = new; else if (compare(head, new) != 0) { …

Member Avatar for ambageo
0
191
Member Avatar for hsetaknev
Member Avatar for Trentacle
0
154
Member Avatar for jimJohnson

If you want a general code review, be sure to ask for it specifically to avoid confusion. I and a few others occasionally tear down programs line by line, point out issues, and suggest better ways of going about a solution, but it's ideal if the program is relatively short …

Member Avatar for Narue
0
92
Member Avatar for TomaCukor

You realize that getchar is reading one character and returning the code value of that character, right? If you type "100", the values you get are likely to be 49, 48, and 48. Is this intended? Because it raises red flags when I read it.

Member Avatar for WaltP
0
265
Member Avatar for MooGeek

Simply churn out code, or code effectively? I can go four hours or so before a break is needed to maintain quality, but if the code can suck ass an all day caffeine fueled code orgy isn't improbable. I refuse to [i]not[/i] get my eight hours of sleep though, so …

Member Avatar for ajst
0
170
Member Avatar for Reverend Jim

I'd speculate that $@ (your target) is a Windows-style path with the "<drive>:\" pattern. The colon from Windows paths can cause this error because suddenly you're looking at an unexpected separator in the pattern rather than a complete target. What does your make invocation on the command line look like?

Member Avatar for nezachem
0
4K
Member Avatar for gpta_varun

[QUOTE]Is it ok to directly copy one object's content onto other ?[/QUOTE] The problem is aliasing. For example, if any of your data members are pointers then an explicit copy constructor is required to make a deep copy of the object. Otherwise the pointers from two objects will point to …

Member Avatar for Fbody
0
162
Member Avatar for Mr_PoP

[code] #include <sstream> #include <string> std::string get_file_name(int sequence_number) { std::stringstream out; out<<"today"<< sequence_number <<".txt"; return out.str(); } ... syslog.open(get_file_name(st.wDay)); [/code] Awkward, huh? :)

Member Avatar for Mr_PoP
0
84
Member Avatar for rtk1865

[QUOTE]the "%s%*c" is adding the comma to the string I sent it to[/QUOTE] Yes, because %s is delimited on whitespace. You need to use a scan set to exclude commas along with whitspace: "%[^ \t\n\r\v\f,]%*c".

Member Avatar for Narue
0
23K
Member Avatar for hao90

Perhaps: [code] public static void main(String[] a) { int[] test = new int[] {0, 1, 2, 3, 4}; reverse(test); for (int i = 0; i < test.length; i++) System.out.print(test[i] + " "); System.out.println(); } [/code] If all you're doing is testing the reverse method, there's really little need to do …

Member Avatar for hao90
0
114
Member Avatar for fka

[QUOTE]Some suggestions?[/QUOTE] You've got the right idea, just expand on it: [code] #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { if (argc > 1) { FILE *in = fopen(argv[1], "r"); if (in != NULL) { char **lines = NULL; char line[BUFSIZ]; size_t i, n = 0; …

Member Avatar for fka
0
135
Member Avatar for rtk1865

[B]>Isn't an fscanf string assignment supposed to work on a char pointer (which is what orig_unit->name is)?[/B] Yes, but pointers aren't magic. You can't simply define a pointer and expect it to point to an infinite amount of usable memory, you must first point it to a block of memory …

Member Avatar for rtk1865
0
205
Member Avatar for ronnieaka

[QUOTE]most of my friends advise me to go for open source development: use LAMP (linux,apache,mysql,php) combination if i ever develop a web app, or use OpenGL if developing desktop apps in c++ so that they can run on linux apart from windows only, or use java if ever getting thoughts …

Member Avatar for absolute_zero
0
316
Member Avatar for DrMAF

Are you using Visual C++ Express? atlstr.h is part of the ATL library which only comes with retail versions of Visual Studio. If you're confident enough to do some hacking, you can use the freely available WTL instead (instructions can be found [URL="http://tech.groups.yahoo.com/group/wtl/message/12850"]here[/URL]). Why do you need that header? When …

Member Avatar for DrMAF
0
4K
Member Avatar for Castiel1631

I think you should only work on one ADT library at a time unless you're already experienced with the task (which you clearly are not, no offense).

Member Avatar for Thaylo
0
1K
Member Avatar for ivan26

What have you tried? Did you encounter any specific problems? Please elaborate on anything that proves you're not a lazy student looking for a hand out.

Member Avatar for floatingDivs
1
240
Member Avatar for phobos666

[B]>The no. of rows varies from 35 to 60.[/B] Then set the size of your arrays to 60. If the number of rows were completely indeterminate (eg. as few as zero and in excess of millions) you would be better served by either a dynamic data structure or an algorithm …

Member Avatar for Narue
0
131
Member Avatar for ateryad

[B]>move down the forum list just a bit more.[/B] And then piss off. This is also a help forum, not a "do all of my work for me" forum.

Member Avatar for Narue
-1
76
Member Avatar for harry.jhone

[B]>Is there any powerfully software available that automatically create software without and coding knowledge.[/B] Nope. There are tools that generate code and facilitate the process without churning out reams of code, but coding knowledge is still required to take advantage of them.

Member Avatar for Narue
0
427
Member Avatar for aplh_ucsc

arr looks to be a global array, so you don't need to pass anything, just use it: [code] #include <stdio.h> int arr[12500]; void print(void) { printf("%d\n", arr[0]); } int main(void) { arr[0] = 123; print(); return 0; } [/code]

Member Avatar for aplh_ucsc
0
202
Member Avatar for miturian

Actually, I'm curious if you've profiled having a, b, and c as non-static members of SIMULATION and verified that it's too slow for your needs. Writing off a viable option because you [i]think[/i] it's not performant isn't the way to go about design.

Member Avatar for mike_2000_17
0
187
Member Avatar for arshi9464

[B]>i meant that why do we need to use data structure?[/B] That's the same question you asked originally. Clearly you're not expressing your question in a way that can be understood, so try rewording it.

Member Avatar for Jason Giggs
0
189
Member Avatar for udaykrishnag

Image formats typically have header information within the file that defines them. You can look up the format of each image type at [URL="http://www.wotsit.org/"]http://www.wotsit.org/[/URL].

Member Avatar for Narue
0
59
Member Avatar for SecLoRum

Of course it's possible. I'll offer advice on how to go about a solution if you provide less vague requirements.

Member Avatar for Jason Giggs
0
118

The End.