6,741 Posted Topics

Member Avatar for DJSAN10

main is a special function because it's the program's entry point. Thus, there's a certain measure of compiler magic involved. During compilation the compiler will determine which version of main to call based on your definition.

Member Avatar for DJSAN10
0
195
Member Avatar for airerdem

[B]>I really need that code[/B] Then write it. That's what I do when I really need code for something. [B]>I have a text file >and I want to convert it vector or array[/B] I'm sure you've used cin's >> operator to read integers from standard input. What you did was …

Member Avatar for Tellalca
0
166
Member Avatar for mano100

Your constructor and class fields are nested inside Main. It should look like this: [code] class Student { private int registrationNumber; private string name; private DateTime DateOfBirth; public Student() { Console.WriteLine("New Student created. Parameterless constructor called...."); } public static void Main(string[] args) { } } [/code]

Member Avatar for mano100
0
420
Member Avatar for jpaterson2525
Member Avatar for chrisbrandon

If you give a wrong answer, someone will likely correct you, which leads to you learning more on top of the original question being answered. I don't see a downside to this process.

Member Avatar for diafol
0
131
Member Avatar for aplh_ucsc

What exactly were you expecting to happen? What you're attempting is rather nonsensical.

Member Avatar for aplh_ucsc
0
111
Member Avatar for shanki himanshu

[B]>Do me 1 favour...[/B] Not only will I do you a favor, it'll be the single best favor you'll ever receive. I'm going to let you bomb this assignment. Then you'll learn that nobody is going to bail you out, that you should only rely on yourself, and you should …

Member Avatar for Kamatari
-8
134
Member Avatar for Don_k

[QUOTE=Don_k;1423916]I know that perhaps a header file is needed(containing filename, size of filename, start and end of file) for extracting these files back out into their original form, but how would I go about doing this.[/QUOTE] Here's a simple example where each file is preceded by a header with the …

Member Avatar for Don_k
0
209
Member Avatar for shri007

[B]>can u do a c++ program without main function.....?[/B] It's splitting hairs, but yes, you can if your compiler supports alternative entry points. For example, Microsoft's CL compiler supports WinMain as an entry point instead of main.

Member Avatar for Nick Evan
0
126
Member Avatar for seriousgeek

Decompilers are genally crap due to the lossy nature of compilation. However, disassemblers are terribly useful provided you're reasonably proficient with assembly language. I like OllyDbg for Windows.

Member Avatar for Narue
0
71
Member Avatar for surajitsweet021

% is the remainder operator. It performs the usual division operation, but evaluates to the remainder instead of the quotient. In your example, 4 can't be divided by 10, so the quotient is 0 and the remainder is 4.

Member Avatar for WaltP
0
152
Member Avatar for mrcpp

You're accessing the array out of bounds. In main, index exceeds 999, which is the largest available index in primes. Anything can happen, including wacky output and crashes.

Member Avatar for mrcpp
0
310
Member Avatar for jackmaverick1

I think the appropriate question in this case is why do you want to invoke the destructor explicitly? It's called automatically at the right time except in some extreme and obscure situations (which you're not likely to encounter for a while).

Member Avatar for jackmaverick1
0
1K
Member Avatar for L.sha

[B]>It works but I dont understand why it is not displaying me the items I have inserted after sorting it.[/B] Um, if the output isn't as expected then it clearly [i]doesn't[/i] work. Looking at your sorting algorithm, aside from it being obviously wrong to a trained eye, temp is an …

Member Avatar for Narue
0
154
Member Avatar for lochnessmonster

[B]>um ok...um ok...[/B] You were expecting some sort of mystery of the universe? The difference is that signed types use half of the range for negative values. With unsigned types you have a wider positive range, and a guarantee of wrapping on overflow/underflow.

Member Avatar for NathanOliver
0
118
Member Avatar for omkar1987

[B]>Don't encourage people to use nonstandard headers.[/B] Indeed, especially when the nonstandard header is also completely unnecessary.

Member Avatar for Narue
0
173
Member Avatar for mightysnake

<broken record> What have you tried so far? Do you have any code? If so, please post it. If not, go give the assignment an honest attempt before asking for help! </broken record>

Member Avatar for mightysnake
0
176
Member Avatar for nxt200

The invocation would look something like this: [code=text] $ g++ file1.cpp file2.cpp file3.cpp $ ./a.out [/code] The header files need not be compiled as the preprocessor textually inserts them into your .cpp files. The resulting executable file is named a.out by default, but you can alter that with the -o …

Member Avatar for Narue
0
183
Member Avatar for vedro-compota

[B]>why it's so?[/B] Enter is a character too, the newline ('\n'). On your system it has a value of 10, so 10 - 48 = -38. Note that your condition fails to catch the newline because you've already changed the value by that time.

Member Avatar for vedro-compota
0
248
Member Avatar for iamuser_2007

[B]>And the assignment called for floating point numbers, not doubles...[/B] Doubles [I]are[/I] floating-point numbers. [iCODE]float[/iCODE] is single precision and [ICODE]double[/ICODE] is double precision. Otherwise I agree with your post. :)

Member Avatar for iamuser_2007
0
293
Member Avatar for jordankaushik

[QUOTE=frogboy77;1423807]very limited knowledge of this but this using ctime appears to give a rough time the code took to run. [CODE]double time=clock(); //program cout<<clock()-time<<" ms"; or cout<<(clock()-time)/1000<<" seconds.";[/CODE][/QUOTE] This is more conventional: [code] #include <iostream> #include <ctime> int main() { std::clock_t start = std::clock(); // ... std::cout<< ((double)std::clock() - start) …

Member Avatar for Narue
0
149
Member Avatar for AmerJamil

Your two if statements are executed every time in sequence, so if you have an upper case letter, it'll be converted to lower case, then back to upper case. If you have a lower case letter, it'll jump over the first if statement and still be converted to upper case. …

Member Avatar for WaltP
-2
478
Member Avatar for vedro-compota
Member Avatar for Farhad.idrees
0
180
Member Avatar for aplh_ucsc

When writing a library you need to take care to only make the names that should be visible to client code extern; the rest should be static for file visibility. Names that are extern should be designed to avoid clashing with client code and other libraries as well. Finally, any …

Member Avatar for aplh_ucsc
0
112
Member Avatar for Narue

Hey Dani, I know you [i]really[/i] want us to use the personalized home page and favorite forums, but is there any chance of a feature for collapsing categories on the main forum list? That's something I very much miss from the previous design.

Member Avatar for Dani
0
117
Member Avatar for thelamb

[B]>Is there any way I can prevent this copy?[/B] No, not really. In calling operator<<, you've bound the temporary object to a reference, which basically invalidates it for further copy elimination. [B]>had I known that it would make copies all the time I would not have done it...[/B] It's best …

Member Avatar for thelamb
0
95
Member Avatar for lochnessmonster

[B]>is there a difference??[/B] The latter will probably give you a warning about loss of precision, but since the value is representable by both float and double, there's no real problem.

Member Avatar for Narue
0
444
Member Avatar for sahil1991

[B]>it 'll be good if i can find links for some good ebooks ........[/B] You'd be better off just picking [URL="http://en.wikipedia.org/wiki/List_of_data_structures"]from a list[/URL] and googling until enlightenment. I don't know of any ebooks (though my own website has thorough tutorials on a a few data structures), and dead tree books …

Member Avatar for Narue
0
166
Member Avatar for stevetaylor15

Unless the method is static, you need an object to call it on. How you go about accessing the method (static, instance, inheritance, etc...) really depends on your design. How do these two classes relate and interact in your application?

Member Avatar for williamrojas78
0
205
Member Avatar for Frederick2
Member Avatar for Fbody
0
147
Member Avatar for MasterGberry
Member Avatar for MasterGberry
0
330
Member Avatar for Don_k

I have a better idea. How about you show us your attempts at writing functions and we can show you where you went wrong? Otherwise you're essentially asking for a full tutorial on how to write functions, which most of us aren't inclined to write.

Member Avatar for nezachem
0
148
Member Avatar for m1n1m3

[B]>Don't use bit fields. They're implementation dependent, not portable.[/B] Bit fields are quite portable, provided you don't make unwarranted assumptions about the storage layout.

Member Avatar for Narue
0
161
Member Avatar for Mona..

Let's say you have an array [ICODE]{a, b, c, d, e}[/ICODE]. Now c is deleted resulting in [ICODE]{a, b, (empty), d, e}[/ICODE]. The avail_list logic would store index 2 such that adding a new item (f) would result in [ICODE]{a, b, f, d, e}[/ICODE] rather than [ICODE]{a, b, (empty), d, …

Member Avatar for Narue
0
228
Member Avatar for gian10890

Use xcopy or robocopy for a bit more control over the operation: [code] xcopy /E /O /V /Y "fedr023818" "Z:\TNT\prod\other projects\FEDERAL REGISTER\FIN MOD" [/code]

Member Avatar for Narue
0
66
Member Avatar for لولا

[B]>cout<<"The array after revers is : " << revers (a) << "\n";[/B] What does revers return?

Member Avatar for Narue
0
95
Member Avatar for hsetaknev

[B]>The exact definition of NULL is compiler dependent, but normally defined as either (char *)0 or just 0.[/B] I haven't seen NULL defined as [ICODE](char*)0[/ICODE] and I don't suspect any compilers have done so after the generic pointer type was introduced to C. While char* and void* have the same …

Member Avatar for hsetaknev
0
152
Member Avatar for phobos666

[B]>scanf("%s",&fnamen);[/B] fnamen is already a pointer in this context. Adding a redundant address-of operator changes the type, which can potentially break your program (though it's usually benign in this case). Also consider that %s without a field width is no better than gets (ie. there's no protection from buffer overflow), …

Member Avatar for Narue
0
32K
Member Avatar for vedro-compota

[B]>fillnumb will be =2[/B] Why would it be? If fillnumb is 0, then that falls into your case 0, which sets fillnumb to 1. A break at the end of a case terminates the switch statement, so execution won't fall through to case 1.

Member Avatar for vedro-compota
0
131
Member Avatar for kitsan

[QUOTE=kitsan;1421345]Can anyone tell me the Coding for: [ATTACH]18596[/ATTACH] Help me!!![/QUOTE] I'd be happy to give you complete code so you don't have to do [i]any[/i] work at all! [code] #include <stdio.h> #include <stdlib.h> #include <math.h> #define f(x) ((x)>0?((x)*((x)+1)/2):0) #define g(x) (((int)sqrt(8.0*(x)+1)-1)/2) int main(int c, char **v) { if (c>1) for …

Member Avatar for Narue
0
136
Member Avatar for AmerJamil

There should be a separate index counter for a and b, because you don't want to skip indices: [code] if (s % 2 == 0) c[s] = a[q++]; else c[s] = b[r++]; [/code]

Member Avatar for Narue
0
253
Member Avatar for harryhaaren

[quote] I've read around, some say [code=c++]vector.swap ( otherVector );[/code] is fastest? [/quote] Typically, but that's not a copy operation. [QUOTE]Let me know if there are fast ways to do this please![/QUOTE] If performance is an issue, it's often better to think squiggly. Instead of making a copy, can get …

Member Avatar for Narue
0
4K
Member Avatar for Don_k

Use a loop: [code] if (argc > 1) { int i; for (i = 1; i < argc; i++) { /* Open and read argv[i] */ } } [/code]

Member Avatar for Don_k
0
223
Member Avatar for karthi_selva

If the pointer is not okay, it should be NULL. Otherwise you have no choice but to always return a valid pointer and test the contents, which you've already stated isn't desirable: [code] #include <stdio.h> char *fun(void) { char *result = NULL; /* Allocate and populate result, or leave NULL …

Member Avatar for karthi_selva
0
171
Member Avatar for bleedi

[url]http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html[/url]

Member Avatar for Narue
0
106
Member Avatar for renork

>small(*array[], &sumc, &sumr, r, h, w); The empty subscript only works for declarations. Either remove [], or remove * and change [] to [0]. Also, &sumc and &sumr are pointers, not int as small expects. This will compile, but it may not do what you want because you clearly have …

Member Avatar for icasta13
0
845
Member Avatar for mumingazi

Bumping your thread is rude. Please use code tags. Specify WTF is wrong with the program if you want help. kthxbye.

Member Avatar for Nick Evan
0
221
Member Avatar for Loc

>You didn't think you could just download experience "matrix style" With all of these books claiming you can learn programming in 24 hours and 10 minutes, or that even dummies and idiots can program, it's reasonable to believe that programming isn't hard when you have no real experience doing it.

Member Avatar for Trepach
0
113
Member Avatar for Mona..

char is a keyword, you can't use it for a variable name. And don't use magic numbers. If you [i]must[/i] rely on ASCII (std::tolower exists for a reason), at least use character literals: [code] if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; [/code]

Member Avatar for Narue
0
203
Member Avatar for Snehamathur

[B]>I was using process.h , now i replaced it with malloc.h.[/B] So you replaced a header which didn't contain the function wanted with a header that might not even exist. Brilliant. And what about including stdlib.h as gerard suggested? That's the correct solution. [B]>Is it correct CIRCULAR implementation??[/B] Assuming you …

Member Avatar for Narue
0
114

The End.