6,741 Posted Topics

Member Avatar for VernonDozier

Put it in your gcc invocation: [code=text] all: run test: test.c gcc -D HELLO test.c -o test run: test ./test clean: rm *~ *.o test [/code]

Member Avatar for VernonDozier
0
176
Member Avatar for jared crook

Clearly you didn't search the forums before asking this question, because it's very common. You need to add a pause at the end of the program because the IDE allocates a console window for it to run. When the program ends, the window is destroyed and closes. The Dev-C++ code …

Member Avatar for Moschops
0
168
Member Avatar for montjoile

[QUOTE]which is the one you use?[/QUOTE] I use several, though my favorite is Visual Studio. If only it weren't so damn slow and resource hungry.

Member Avatar for katmai539
0
126
Member Avatar for dyingatmidnight
Member Avatar for m4ster_r0shi
0
1K
Member Avatar for Lost in Code...

[QUOTE=charlybones;1583304]Also, you *might* want to do [CODE]fflush(stdin);[/CODE] right before every single "scanf" that you have. Regards.[/QUOTE] You might, if you want to suffer from [URL="http://www.eskimo.com/~scs/readings/undef.950311.html"]undefined behavior[/URL]. fflush is not defined for input streams and is the incorrect way of discarding unextracted input. The correct way is a loop: [code] void …

Member Avatar for bajishareef
0
6K
Member Avatar for arshi9464

[QUOTE]i want to know, what kind of addresses do pointers deal with?[/QUOTE] That's not specified. [QUOTE]and how can i access a particular memory area using pointers?[/QUOTE] It's not portable, but traditionally that's been done by something like this: [code] /* Point to address 0x12345678 and treat it as an int …

Member Avatar for TrustyTony
0
151
Member Avatar for sharathg.satya

So you want to print an unknown, variable range of numbers, without using any form of loop or recursion. Pretty much any solution with those restrictions will rely on a hidden loop or recursion at a deeper level. It becomes a question of semantics: "Is this enough of a loop …

Member Avatar for bajishareef
0
274
Member Avatar for jdarrel006

This isn't directly relevant, but have you tried not using Turbo C? It has limitations that will be terribly frustrating on modern hardware.

Member Avatar for Adak
0
81
Member Avatar for vedro-compota

I suspect what you want are [URL="http://msdn.microsoft.com/en-us/library/tk67c2t8(v=VS.100).aspx"]property attributes[/URL] that affect how the property is displayed in a property grid control. If your class is more than just a design-time component, you can also make use of the [URL="http://msdn.microsoft.com/en-us/library/aa302326.aspx"]PropertyGrid control[/URL] directly in your own applications.

Member Avatar for vedro-compota
0
240
Member Avatar for niggz

You open the file for writing on each iteration. This truncates it to zero length before writing. Try opening the file before the loop and leaving it open until after the loop completes.

Member Avatar for niggz
0
158
Member Avatar for cheenu02

*sigh* Here's a correct and portable program that does what r0shi and possibly the OP wanted: [code] #include <stdio.h> #include <stddef.h> int main(void) { int a[2]; // Guarantee that the addresses exist int *p = a; int *q = p++; // Casting to char* to get a byte count ptrdiff_t …

Member Avatar for bajishareef
0
2K
Member Avatar for airerdem

Presumably you're using a vector of std::string. The fstream constructors don't have an overload for std::string, so you need to call c_str(): [code] ifstream file(files[0].c_str()); [/code]

Member Avatar for airerdem
0
94
Member Avatar for btowne2

I see you didn't read our rules or the stickies. Specifically, we don't give homework help without some evidence that you've made an honest attempt to do it yourself.

Member Avatar for Narue
0
96
Member Avatar for vincenzorm117

The %d specifier prints a signed int. If you want to print an unsigned value, use %u. Also, you'd be better off using INT_MIN, INT_MAX, and UINT_MAX from limits.h. That'll protect you from the off-by-one trap that you fell into with 4294967296.

Member Avatar for vincenzorm117
0
621
Member Avatar for mrnutty

[QUOTE]And do you need any more information or is this snippet sufficient to guess correctly?[/QUOTE] The correct answer is "send the code back to the author with a bug report". Copying bytes into an int punned as char* is only safe when the bytes being copied were acquired from another …

Member Avatar for Moschops
0
144
Member Avatar for asrockw7

[URL="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1048384015&id=1043284392"]Clicky[/URL].

Member Avatar for vegaseat
0
7K
Member Avatar for Vinod Supnekar

EOF isn't a character, it's a flag returned by getchar denoting end-of-file. You can signal end-of-file from the command prompt (assuming Windows) with the Ctrl+Z keyboard combination. If you want to print the value of EOF, I'd suggest using printf: [code] printf("EOF: %d\n", EOF); [/code]

Member Avatar for Ancient Dragon
0
444
Member Avatar for dotancohen

[QUOTE]I just read in K&R that a function, even if not defined as void, need not return a value.[/QUOTE] What page? From memory, the only place where K&R makes such a grievous mistake is in the beginning tutorial with the initial definitions of main. However, that's a pedagogical decision that …

Member Avatar for vegaseat
0
200
Member Avatar for mariko

[QUOTE]Is there a difference between programming and scripting?[/QUOTE] This question cannot be answered until you clearly define what you mean by "programming" and "scripting".

Member Avatar for vegaseat
0
165
Member Avatar for phalaris_trip

[QUOTE=Luckychap;607133]I think the node structure should be like this: [CODE] struct node { void *data; int type; struct node *next; struct node *prev; }LINK; [/CODE] where: [B]type[/B] is used for type. For example type=1 indicates int, type=2 indicates float, type=3 indicates userdefine and so on... and Insert function will look …

Member Avatar for MonsieurPointer
0
4K
Member Avatar for evaldaskowka

[QUOTE]But it's C i cant make it to work with C++[/QUOTE] Be more specific. Why doesn't it work with C++? Are you getting compilation errors? Runtime errors?

Member Avatar for Ancient Dragon
0
220
Member Avatar for learningcpp

[QUOTE]What is the scope of the exception variables when I catch them by reference.[/QUOTE] I think you mean what is the [i]lifetime[/i] of exception objects. Because the scope is a trivial question: the scope of an exception variable, whether caught by value, pointer, or reference, is the catch block. The …

Member Avatar for learningcpp
0
202
Member Avatar for mitrious
Member Avatar for mitrious
0
148
Member Avatar for massivefermion

[QUOTE]I know C++ well and have written some programs in it but when I look at a program's code,I can't understand it.[/QUOTE] There's a difference between knowing C++ and knowing how to program in C++. "Real world" programming involves more than just the language. There needs to be an understanding …

Member Avatar for Ancient Dragon
0
440
Member Avatar for manish250

[QUOTE]int *ptr=50;[/QUOTE] This is attempting to point [ICODE]ptr[/ICODE] to address 50. Typically, you can only point to addresses within your process' address space, otherwise you'll get a segmentation fault. Java references are actually gimped pointers, which should give you an idea of how to use C pointers for basic object …

Member Avatar for bajishareef
0
144
Member Avatar for jingda

When it comes to being mods, I think we're all losers. But our loss is Daniweb's gain. ;) [QUOTE]Winner gets to delete all spam in the marketing forums for six months.[/QUOTE] That's easy, just delete all new posts every time you log in. :D

Member Avatar for jingda
-1
126
Member Avatar for kandarpa

[QUOTE]I have used calloc(), instead of combination of malloc and memset as a work around.[/QUOTE] calloc is the functional equivalent of malloc + memset. It might be faster due to the potential for standard library optimization over hand rolled code, but probably not enough to make a big difference. Have …

Member Avatar for N1GHTS
0
3K
Member Avatar for AW8Dragon

[QUOTE]the problem is in this part, in case u can't find it in the code above[/QUOTE] So are the preceding 1500 lines relevant or not?

Member Avatar for AW8Dragon
0
408
Member Avatar for emmaand

[QUOTE]mayb the problem is when you still have to work on next program, so with return 0 it will end current program and start the next? but with system("exit") it will totally close it?[/QUOTE] That's an impressive feat of misplaced logic. No, you were correct in saying that [iCODE]system("exit")[/iCODE] is …

Member Avatar for murnesty
0
8K
Member Avatar for niggz

You need a way to point back to the [ICODE]coms[/ICODE] index after sorting [ICODE]table[/ICODE]. Rather than a sorted array, I'd go with a map: [code] void standings(userClub uc){ map<int, int> table; for(int i=0; i<9; i++){ table[coms[i].pts] = i; } table[uc.pts]=9; map<int, int>::const_iterator it = table.begin(); map<int, int>::const_iterator end = table.end(); …

Member Avatar for niggz
0
411
Member Avatar for MareoRaft

[QUOTE]you should always use the int main(int nargs, args[]);, it is better then just int main()[/QUOTE] Please explain why it's better.

Member Avatar for Raphaelnad
0
458
Member Avatar for programing

I think you need to go back to your teacher and get some details. Asking you to create a compiler, regardless of size, in an intro to programming course is a little excessive.

Member Avatar for rubberman
0
245
Member Avatar for Michael27
Member Avatar for kevinmax101

You're doubling the direction test. [ICODE]x[/ICODE] or [ICODE]y[/ICODE] is already adjusted in the call to movePlayer, and you further adjust it when setting [ICODE]ch[/ICODE] in movePlayer. One possible fix is removing the switch in movePlayer and just setting [ICODE]ch[/ICODE] to [ICODE]map[x][y][/ICODE] in all cases.

Member Avatar for TrustyTony
0
1K
Member Avatar for Lilcrew

[QUOTE]I know the getch() is old and non-standard, but cin.get() does not work for me in some situations, so I thought I should mention getch() .[/QUOTE] What situations? Using an input block to pause the program really only gets hampered by one thing: a non-empty stream. getch() always works because …

Member Avatar for NathanOliver
0
303
Member Avatar for M1n1m@l1$t

Until you know the rules for braces, it's best to always use them: [code] if (secretnum<getint) { cout<<"try a lower number"; goto loop; } else if (secretnum>getint) { cout<<"try a higher number"; goto loop; } else { cout<<"that is correct"; } [/code] By the way, you should also avoid goto …

Member Avatar for m4ster_r0shi
0
783
Member Avatar for crapgarden

[QUOTE]All POST operations are performed at the end of a statement, and all PRE operations are performed at the beginning of a statement. Is that correct?[/QUOTE] It's close enough, yes. To be strictly precise, the update can happen any time between the previous and next sequence point as long as …

Member Avatar for crapgarden
0
120
Member Avatar for UltimateKnight

[QUOTE]I need to add this to the output statement?[/QUOTE] SetColors needs to be called with appropriate arguments before the output you want with a different color. It's also not a bad idea to save the current color attributes and restore them when you're done. That's pretty trivial with a sentry …

Member Avatar for UltimateKnight
0
235
Member Avatar for illIAm
Member Avatar for Narue
0
208
Member Avatar for cosmoss

[QUOTE]Who do you think this guy is?[/QUOTE] What makes you think he's anything other than a model hired for that photo?

Member Avatar for Salem
0
543
Member Avatar for Buolbear4444
Member Avatar for FriXionX

[B]>if(chooseType == "a" || "A"){[/B] C++ parses it like this: [code] if(chooseType == "a" || "A" != 0){ [/code] Adjust accordingly.

Member Avatar for FriXionX
0
118
Member Avatar for localp
Member Avatar for UltimateKnight

[QUOTE]So is the compiler not good?[/QUOTE] The compiler that ships with Visual C++ is quite good. Your problem is very vague, but I suspect you're trying to use non-portable stuff. Can you give an example of what code "is not working"?

Member Avatar for UltimateKnight
0
102
Member Avatar for Nicco

For the record, hiding a pointer behind a typedef is a fantastic way to confuse both yourself and others.

Member Avatar for Nicco
0
2K
Member Avatar for DOT6

I'll save you the trouble of searching around: [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/"]qsort[/URL].

Member Avatar for Narue
0
256
Member Avatar for yoni0505

To answer the question in your title, yes. write's first argument must be a pointer to char where the number of available characters starting at that pointer match the second argument. [QUOTE]everything between these values became null.[/QUOTE] Can you elaborate? What do you want to happen (with examples) and what's …

Member Avatar for yoni0505
0
363
Member Avatar for MareoRaft

[QUOTE]Do you know what could be the issue?[/QUOTE] Yes, the issue is you not understanding how substr works. The second argument is a count, not an index.

Member Avatar for MareoRaft
0
537
Member Avatar for theguitarist

[QUOTE]But shouldn't I clear out the input stream before I use cin again?[/QUOTE] How do you know that it needs to be cleared? What if the next request for input corresponds to whatever is already in the stream? I can type "123 4.5 booga" all on one line and the …

Member Avatar for theguitarist
0
2K
Member Avatar for Freude

Assuming your matrix is a two dimensional array, and the function takes a one dimensional array of the same type, you can do this: [code] some_function(my_matrix[3]); [/code] I'm assuming a lot because you didn't provide nearly enough information to properly answer the question.

Member Avatar for mike_2000_17
0
189

The End.