556 Posted Topics

Member Avatar for vivek nandan

OK to start with if you enter a string longer than 3 characters you overwrite the end of the allocated buffer. Writing outside the bounds of a valid object results in undefined behaviour. Once you have undefined behaviour anything may happen. You should use the function [icode]fgets[/icode] rather than [icode]gets[/icode] …

Member Avatar for Banfa
0
115
Member Avatar for CoopOwnz

May I ask how you process the e example since [icode]cout<<(char)1154;[/icode] is equally likely not to work?

Member Avatar for Banfa
0
139
Member Avatar for onus

How about you don't try and individually allocate and reserve each byte of memory. Also is there any reason why you are doing it in 2 dimensions? Why a metric of mxn bytes and not just a flat p bytes (where p = n*m)? So if you have a flat …

Member Avatar for Banfa
0
145
Member Avatar for tikoti

Your problem is most likely in stot with the variable tInfo which you use without initialising all its members, specifically tInfo.tm_wday, tInfo.tm_yday and tInfo.tm_isdst. The first 2 of which can be initialised to 0 they seem to be corrected by mktime although that may just be an implementation feature but …

Member Avatar for tikoti
0
190
Member Avatar for aaronmk2

You are right about the coding not being good because it alters degree, in fact operator+ and all binary operators and act on 2 operands to produce a new result are best declared const `Poly Poly:: operator+(const Poly& p) const;`. That way the compiler enforces the policy of not changing …

Member Avatar for caut_baia
0
162
Member Avatar for sundip

You can't do that. The best you can do is have an array of structures containing the names and the appropriate function pointer so you can look up the name in the array and then call the associated function pointer.

Member Avatar for sundip
0
259
Member Avatar for amala.123

I have seen and used this trick before. The file memp_std will contain a list of items defining the memory pools for the system something like this [code] LWIP_MEMPOOL(Pool1,100,8,"8 byte pool") LWIP_MEMPOOL(Pool2,100,16,"16 byte pool") LWIP_MEMPOOL(Pool3,100,32,"32 byte pool") LWIP_MEMPOOL(Pool4,100,64,"64 byte pool") ... [/code] normally without inclusion tags. Then when you want …

Member Avatar for amala.123
1
658
Member Avatar for Jennifer84

Line 35, you add to [icode]text[/icode] which is declared as a handle at line 9 but never gets an object assigned to it. I think, with my very limited knowledge of .NET, you need to [icode]gcnew String[/icode] an object to text.

Member Avatar for Milton Neal
0
317
Member Avatar for gozlemci

It has no formal definition so its meaning is defined by the context. Normally it just means group of related things so a module could be a group of related classes or a group of related source files, possible with-in a single process or in separate processes. I think in …

Member Avatar for gozlemci
0
2K
Member Avatar for mainstreetmark

Instead of [icode]lib/ft/libmbusmaster.a[/icode] on the g++ command line try [icode]-llib/ft/libmbusmaster.a[/icode] or [icode]-l lib/ft/libmbusmaster.a[/icode]

Member Avatar for mainstreetmark
0
305
Member Avatar for challarao

You are overwriting your arrays, when you declare a variable [icode]char str1[]=""[/icode] since you have not specified an array length but you have specified an array initialiser the compiler allocates exactly the right array size to fit the initialiser into it. In your case an array size of 1 or …

Member Avatar for Banfa
0
112
Member Avatar for galmca

I hope not because 1 is not a prime number* and 2 is. You have already got code that checks a number to see if it is prime in your own post (although it code stand some optimisation). All you have to do is repeat that in a loop for …

Member Avatar for ramesh thota
0
469
Member Avatar for shabir_24
Re: QT

You should not be much effort at all to convert std::list<employeeObject> to QValueList<employeeObject>. In fact all you need to do is change the type. QT containers are compatible with the STL so you can use pretty much all the STL algorithms on a QValueList as you would on a std::list.

Member Avatar for Banfa
0
122
Member Avatar for suvcss

That is right you can directly compare C style string using ==. You need to use the library function [icode]strcmp[/icode]

Member Avatar for suvcss
0
2K
Member Avatar for malvi

You could set a timer and do the edit box update in response to the timer event. Of course what will make it very hard for the user to edit the contents.

Member Avatar for Ancient Dragon
0
168
Member Avatar for ttx336

Tokens are just a group of characters that have been delimited in some way. So for instance you might talk about tokenising a string of comma separated values into tokens. You would mean extracting the strings appearing between the commas as separate values. Tokenising is often, but not necessarily, done …

Member Avatar for ttx336
0
97
Member Avatar for cktbrd

This [icode]s[0]&0x0F[/icode] is an unusual way to convert and ASCII digit to its binary equivalent and is not portable relying on the actual character values in the ASCII character set. A slightly more usual way and one that is portable would be [icode]s[0] - '0'[/icode] which rather than relying on …

Member Avatar for kings_mitra
0
270
Member Avatar for beyondavatars
Member Avatar for vttuning

Line 12 you declare Imprime as [icode]void Imprime(int numerocarro, int numlugar, int situacao, int tempo);[/icode] then line 93 you define it as [icode]# void Imprime(int numerocarro, int numlugar, int situacao, float tempo){[/icode]. The type of the last parameter differs which is a mistake. The compiler compiles your code assuming the …

Member Avatar for vttuning
0
133
Member Avatar for iqra123
Member Avatar for Banfa
0
2K
Member Avatar for midget66

There are plenty of other cases where you might have a loop with no body. Any calculation or algorithm where the loop actually does the calculation, for instance finding the end of a singly linked list [code] // Should check head is not NULL before this for(current=head; current->next != NULL; …

Member Avatar for kings_mitra
0
129
Member Avatar for shankarz

Generally speaking a definition actually creates something while a declaration just tells the compiler it exists. This can be done for both variables and functions. A variable definition can also include a value for initialisation. So for variables [code] // Assume all at file scope int i; // This is …

Member Avatar for Banfa
0
197
Member Avatar for ravimodi

How do you propose to get round users changing the lan card because it has gone wrong, or something similar? With this methodology you strictly do not need to be able to recover the MAC-ID from the encrypted text file. All you need to do is re-encrypt the MAC-ID and …

Member Avatar for Banfa
0
79
Member Avatar for rapids79

A good TCP/IP (and UDP) primer is [url=http://beej.us/guide/bgnet/]Beej's Guide to Network Programming[/url] which is downloadable in various formats or available as an actual book. @kings_mitra Doh you beat me to it :D

Member Avatar for technology
0
157
Member Avatar for YoavX

You probably should declare clientaddr as a SOCKADDR_STORAGE rather than a sockaddr_in to ensure that clientaddr is large enough for any data that accept might write to it. However that may not actually cure your problem.

Member Avatar for Aranarth
0
141
Member Avatar for vbx_wx
Member Avatar for kymarscheng

I like Eclipse since it is cross platform, I don't have to remember different keyboard short-cuts as a switch back and forth between Linux and Windows. Although it does have a few features I find irritating, but is also has features I miss when using VC++. CodeBlocks is good too …

Member Avatar for tokenjoker187
0
257
Member Avatar for noobuser

Actually for an array with program lifetime (i.e. one not declare in a function or declared static in a function) you don't even need the [icode] = {0}[/icode]. The compiler initialises all such arrays and variables to 0 if no other value is given.

Member Avatar for Ancient Dragon
0
207
Member Avatar for Hawking
Member Avatar for whattever

Was that all the errors? Having the complete text of the error messages would help (unless that's also in Japanese). I couple of points main returns int, returning default int without a warning tends to suggest you are using an old compiler. Using capital letters for you function names is …

Member Avatar for nbaztec
0
503
Member Avatar for cmsc

itoa is not an ANSI/ISO standard function and is non-portable, also it converts an integer to a string not a string to an integer. Try atoi or strtol

Member Avatar for cmsc
0
81
Member Avatar for dhruv_arora

you have not defined the return types of several of your member functions making the compiler think they are incorrectly named constructors.

Member Avatar for Ancient Dragon
0
349
Member Avatar for highflyer8

I think your problem is as the iteration continues fsum gets bigger while term gets smaller. At some point you reach a stage where term is small enough that it can not accurately be added to fsum because of accuracy issues. This test program highlights the problem [code] #include <iostream> …

Member Avatar for arkoenig
0
1K
Member Avatar for Leppie

You have 4 {, every dimension of array requires a { so you have 1 too many. You inner most array initialisers have 10 entries, but the last dimension of you array has a size of 3. The sizes do not match. Looking how you have laid out the data …

Member Avatar for Leppie
0
185
Member Avatar for iqra123

Line 8, you get an integer, presumably you input either 1 or 2. But in your case statements you using '1' and '2', these are the characters 1 and 2 and respective have the values 49 and 50 (assuming ASCII) so your 1 and 2 input don't match. Using the …

Member Avatar for iqra123
0
72
Member Avatar for eshabajaj
Re: C

Every compiler has 2 character sets, the source/compiler character set, that is the character set the compiler uses to read the source files and the execution character set, that is the character set that the produced program will use while it is running. Apart from that the C standard doesn't …

Member Avatar for Banfa
0
88
Member Avatar for xaop

Line 14 - 17 what???? Have you not heard of else if [code] if (i >= 1000) { n = 4; } else if (i >= 100) { n = 3; } ... [/code] Line 19 - 22 what ??? Have you not heard of the modulus operator % Line …

Member Avatar for Banfa
0
145
Member Avatar for usafsatwide

Line 27 (and 66) [icode]void GetMovieInfo(MovieData &m1, &m2)[/icode] Every function parameter needs to have its type fully defined. [icode]void GetMovieInfo(MovieData &m1, MovieData &m2)[/icode] it is not like declaring a list of variables [icode]MovieData m1, m2;[/icode] Also I would have thought you teacher will want to see functions taking a single …

Member Avatar for NathanOliver
0
422
Member Avatar for shadowuy

Also in the function RandomArrayFill the code puts 1 more value than there is space for in the array. That is if numero is 5 and array of 5 ints would be allocated (after the fix above) and passed to RandomArrayFill but this function would then write 6 integers into …

Member Avatar for thelamb
0
175
Member Avatar for panda_pow

Take it out of students::AddStudent and add it as a static data member of class students. BTW line 16 is a waste of time, you may as well just change line 4 to [icode]class STUDENTS {[/icode]

Member Avatar for panda_pow
0
150
Member Avatar for parisa_bala

You have a structure, prt_interpln which contains 2 arrays of pointers size 2 and you declare a pointer to that structure interp_coeff. So you have 5 pointers, 1 to to the structure itself and 4 inside the structure to arrays of double. All of these pointers need memory allocated and …

Member Avatar for Banfa
0
174
Member Avatar for mukundyk

Functions are in the global scope, you can return a pointer to any function (even a static one) and the pointer will be valid. The address might well be the address of the first instruction in the function however the true answer to your question is that it is platform …

Member Avatar for Banfa
0
143
Member Avatar for fougere

[QUOTE=NathanOliver;1249486]yes there is a rule. types are promoted to a higher type if assigned to a higher type. going from a higher type to a lower type works as well but there can be truncation of the number[/QUOTE]That's not the complete picture, types are promoted to a higher type if …

Member Avatar for fougere
0
91
Member Avatar for btml

On line 70 you test [icode]table[index].next[/icode], table is passed from main where it is declared as an automatic variable. it is never initialised therefore the first time this test is performed it is unlikely that table[index].next is NULL so no memory is allocated for it and instead the program proceeds …

Member Avatar for Banfa
0
173
Member Avatar for omGac0W

You have put single quotes round a series of 3 characters, 'yes'. However single quotes are used to delimit a single character 'a' '5' 'V' `'*'` `'\t'` (<--- it's a single tab character). If you want a string you need to use double quotes like this "yes", note that a …

Member Avatar for Banfa
0
1K
Member Avatar for tskellyfla

You need to start by working out what data type you will use. Clearly the largest number you will have to deal with is [TEX]$F_{100}$[/TEX] which is 354224848179261915075, a fact you can verify with a simple web search. What data types do you have available that might hold that number? …

Member Avatar for tesuji
0
106
Member Avatar for urbangeek

[QUOTE=urbangeek;1248804]But my question is for [icode]SQ(a+2)[/icode] >> [iCODE]a+(2*a)+2[/iCODE]...that means when a=5 the answer is 17.[/QUOTE] You could easily follow the same process griswolf already did he left out the - but put it in and you get -SQ(a+2) == -a+2*a+2 == -a+(2*a)+2 == a+2 Therefore for a=5, -SQ(a+2) == 5 …

Member Avatar for urbangeek
0
163
Member Avatar for jerryjerry

[QUOTE=jerryjerry;1247615]Through getter setter methods we can indirectly access private data members of the class as shown in the below code. Then what is the significance of encapsulation in OOPS concept. I am not getting the appropiate answer for that. Can anyone help me?[/QUOTE]Actually with getters and setters you are not …

Member Avatar for Fbody
0
155
Member Avatar for sksingh73

You ought to be able to write a QT application that wraps your classes without needing to change them... assuming that you dsign in the first place separated user interface from implementation for example class don't cout data, the return strings which the user interface then couts.

Member Avatar for iamthwee
0
292
Member Avatar for prashanth s j

Of course it prints the ASCII values of 1 and 2, because when you created the string of characters you initialised it with ASCII characters so unsurprisingly that is the values contained. When you say "I want to read from an array two bytes and print then as a short …

Member Avatar for prashanth s j
0
194

The End.