636 Posted Topics

Member Avatar for BoB3R

You have a number of problems here. 1. EOF is a constant, it is equal to -1. It never changes. If you what to know when you hit end of file, watch for the value returned by fread(). It will become 0. 2. Your "j" loop is really strange. Do …

Member Avatar for kvprajapati
0
172
Member Avatar for nschessnerd

[QUOTE][CODE](int)tmp[i][/CODE][/QUOTE] Shouldn't it be [icode]VkKeyScan(tmp[i])[/icode]?

Member Avatar for nschessnerd
0
122
Member Avatar for breakbone
Member Avatar for lostangel556

Your problem is that the line [QUOTE][CODE]comports[0]=CreateFile("\\\\.\\COM6", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL);[/CODE][/QUOTE] is outside any function. Thus is is treated by compiler as a definition of a global array of size 0 with an initializer. Move it into main, or some other appropriate function. PS: Oops. Missed the second page.

Member Avatar for nezachem
0
205
Member Avatar for kinvaras

What have you done so far? PS: I am a psychic, but even I cannot tell the instruction set of [QUOTE]a pedagogical processor[/QUOTE]

Member Avatar for Salem
0
108
Member Avatar for phil750

[QUOTE][CODE]while ( ( current[14] = fgetc( file ) ) != EOF)[/CODE][/QUOTE] The program (repeatedly) reads the whole file, one character at a time, into the same byte, which also happen to be outside of the [icode]current[/icode] array. What you want is [CODE]for(i = 0; (current[i] = fgetc(file)) != '\n'; i++)[/CODE] …

Member Avatar for phil750
0
116
Member Avatar for cwarn23

[QUOTE]It is meant to be a string array[/QUOTE] However you define it as [QUOTE][CODE]std::string result;[/CODE][/QUOTE] that is a single string. I am afraid AD didn't realize what you are trying to achieve and pushed you in the wrong direction. Disregard his advice from post #2, yet honor one from the …

Member Avatar for Ancient Dragon
1
205
Member Avatar for tinkeydo

[QUOTE][CODE] int counter;[/CODE] [/QUOTE] You need to initialize it to 0.

Member Avatar for tinkeydo
0
397
Member Avatar for sarah_laz

First of all, in C you cannot compare strings with comparison operators. They only compare pointers, not the string data. You must use [icode]strcmp[/icode], as in [icode]strcmp(*mid, sample[0]) != 0[/icode]. Next, I am afraid that dict[i] are not what you think they are. They are [B]dict array values[/B], that is …

Member Avatar for sarah_laz
3
1K
Member Avatar for Namibnat

A single computer may run a bunch of network applications simultaneously. Each incoming network packet must be routed to a particular one. Since the network layer has no idea of applications, the routing is done by means of ports. An applications (say, a server) binds its socket to a specific …

Member Avatar for Namibnat
0
125
Member Avatar for azjherben

Yet another buffer overflow, I suppose. How much space did you allocate for [icode]char buffer[/icode]?

Member Avatar for nezachem
0
152
Member Avatar for thisismyuname

[QUOTE][CODE]out << quint16(0) << hello << version << clientType << length << identifier;[/CODE][/QUOTE] First of all, you are violating the protocol. As described, it requires that the packet starts with the length of the whole packet as a 4 byte value. Second, Version and ClientType are one byte each; you …

Member Avatar for nezachem
0
564
Member Avatar for komyg

If neither cygwin nor PowerShell is an option, you can try to play with [icode]FOR /F[/icode]. Look [URL="http://en.wikibooks.org/wiki/Windows_Programming/Programming_CMD#FOR_looping"]here[/URL] for examples.

Member Avatar for Salem
0
150
Member Avatar for Hofik

Another obvious bug is at line 101 (length of a last line is not tested). Also, can you explain the logic of line 126, particularly a [icode]len-3[/icode] part? I strongly suspect your problem is there.

Member Avatar for Hofik
1
87
Member Avatar for Ihatepullups

Look closely at line 26. You read one character, whereas user entered two of them: don't forget that she hit enter. This enter is consumed at line 18 next time around, which results in an empty username. PS: do not use ascii codes in comparisons.

Member Avatar for niyasc
1
109
Member Avatar for digitaldust
Member Avatar for woooee
0
145
Member Avatar for greatkraw

The answer is really simple indeed. You do append. You just print your roll incorrectly. Hint: why do you print the header inside the loop?

Member Avatar for woooee
0
109
Member Avatar for kbalamuk
Member Avatar for DaHandy

A simple answer: you put 3 bytes into a 2-byte array. What actually happens: The arrays are allocated at the stack, next to each other, in order year/month/day (from lower addresses to higher). month[2] is the same as day[0]. A classic buffer overflow.

Member Avatar for DaHandy
0
100
Member Avatar for Iam3R

[QUOTE=Iam3R;1093124]As far as my understanding and other referals i understood that when the address of a local variable is returned the first call using this address may print the correct value but if it is called after any other function may get undefined values. but my program is returning the …

Member Avatar for Tajon Wong
0
361
Member Avatar for daudiam

[QUOTE]getch() returns 26 (ascii for ctrl+z, which indicates the end of input in Windows)[/QUOTE] That's a very usual misconception. First of all, ctrl+z is only significant for text mode streams. Second, for text mode streams, ctrl+z is handled by the driver. It is the driver who encounters ctrl+z, and in …

Member Avatar for nezachem
0
147
Member Avatar for snarb

First thing which comes to mind is Silk. However it costs fortune, so look for free frontend QA tools. I am not an expert in QA, and can't recommend any. If your games are browser-based, and you use extensible browser like Firefox or Chrome, study their extension mechanisms.

Member Avatar for nats01282
0
101
Member Avatar for krishnampkkm

[QUOTE=krishnampkkm;1090442] I don't know how to use #define with this program.[/QUOTE] Question is, why do you [B]want[/B] to use #define in your program?

Member Avatar for krishnampkkm
-2
135
Member Avatar for daudiam

[QUOTE=Narue;1090256][B]It's on our list of "if you don't implement this, you fail as a compiler writer" bullet points.[/QUOTE] I have to disagree here. A performance of pre- vs post- very much depends on the target architecture. For example, cpu32 has (Ax)++ and --(Ax) addressing modes (intended for stack operations), which …

Member Avatar for nezachem
0
637
Member Avatar for Excizted

If you printed it as hex ("%x"), you'd see 10102, which contains ALL the numbers defined as VERSION_***. << is a shift operator. A major is 1 shifted left by 16 bits, a minor is 1 shifted left by 8 bits, a patch not shifted at all. Now they can …

Member Avatar for Excizted
0
149
Member Avatar for doraemon79
Member Avatar for johndoe444

From what I see in your log, all sockets were created fine, yet non of them successfully connected (you print the [B]client: connect[/B] message on connect failure). Now the question is why only one thread reaches line 58. Hard to tell, I would look closely for the deadlock in write_to_log_file. …

Member Avatar for nezachem
0
180
Member Avatar for overpower8

It would be most helpful to have a minimal piece of code [B]which builds[/B] and demonstrates the unwanted behavior. Otherwise we can only guess. Usually you need to flush the stream between writes and reads.

Member Avatar for overpower8
0
108
Member Avatar for ShortYute

First, I do not understand the sacral meaning of a number 6, especially at line 33. Maybe you know something about how the file is arranged, but in any case I would not rely on magic numbers. In your situation I'd get rid of line 33, and moved line 32 …

Member Avatar for WaltP
0
129
Member Avatar for NicAx64

You don't seem to call print. Your code only calls printf (see line 16 of a nasm code), passing argument as it to print. Of course printf gets confused and segfaults. PS: You have a debugger. Why didn't you use it? [CODE]b main run si si si si si[/CODE] and …

Member Avatar for NicAx64
0
203
Member Avatar for Silvershaft

I was wondering should I learn assembly Yes. But please do realize that in your whole programming career you almost certainly will never ever write a single line of the assembly code. So, why bother? A simple answer is to understand how the machinery underneath your C++ really works. Study …

Member Avatar for nezachem
0
115
Member Avatar for Iam3R

Maybe I am missing something. [QUOTE=Iam3R;1088886] here i cannot use my bsearch function. [/QUOTE] Why? [QUOTE] all the keywords and operators are arranged in the array in increasing ascii value of characters for single charcater operators. but how to handle the assignment and relational operators.[/QUOTE] Can you just change the …

Member Avatar for Narue
0
83
Member Avatar for JaiChand2

Did you use a debugger? Meanwhile, there are few problems here. First, the amicablePair array is allocated, but not initialized. Its elements, which are supposed to be of type int * are garbage pointers. As soon as you try to access them (at lines 55 and 56) you have your …

Member Avatar for nezachem
-2
97
Member Avatar for anatz

[QUOTE=anatz;1088825]i just want to ask some tips to understand easily [B]turbo c[/B].,.[/QUOTE] Tip #1: don't use it.

Member Avatar for gerard4143
0
76
Member Avatar for Ancient Dragon

I wouldn't go that far to declare this code wrong. However, such simplistic approach is inherently dangerous. See for example this [URL="http://blogs.msdn.com/oldnewthing/archive/2004/12/27/332704.aspx"]article[/URL]. For more details, also look at [URL="http://blogs.msdn.com/oldnewthing/archive/2004/12/28/336219.aspx"]this[/URL].

Member Avatar for Ancient Dragon
5
5K
Member Avatar for jp071

It is always a good idea to run your code in the debugger. Meanwhile, a line 3 allocates just as much memory as needed to hold the initializing string. An attempt to catenate something to it results in some stack portion corruption, overwriting most likely the state_in (even if you …

Member Avatar for jp071
0
251
Member Avatar for new programer
Member Avatar for nezachem
0
79
Member Avatar for crazysoul13
Member Avatar for monkey_king

[QUOTE]assignment is a sideeffect?[/QUOTE] Yes. [CODE] if((ifd=open(filename,O_RDONLY))<3)[/CODE] means: 1. assign the value returned by open to ifd 2. compare it to 3 whereas [CODE]if(ifd=open(filename,O_RDONLY)<3)[/CODE] means: 1. compare the value returned by open to 3 2. assign the boolean result of the comparison to ifd

Member Avatar for monkey_king
0
126
Member Avatar for monkey_king

[QUOTE][CODE] const char *infile = "bigfile.dat"; size_t bytes_read, bytes_expected = fsize(infile); [/CODE][/QUOTE] Don't you think that fsize better works on a FILE *, rather than char *?

Member Avatar for monkey_king
0
145
Member Avatar for mrnutty

All right, here goes a challenge. Please forgive me if it is well-known already. Also, it is not really a programming challenge, but rather a brain warmer (still any code is welcome). Anyway: A crew of N pirates is going to distribute a bounty of M doublons according to the …

Member Avatar for cwarn23
1
283
Member Avatar for kbalamuk
Member Avatar for myamzen

[QUOTE=myamzen;1083244]Hello everyone, I am new to assembly, and I am trying to learn it. I was given a book by one of my professor to read over the Holidays unfortunately the book assumes basic knowledge in Assembly (BTW, the book is "See MIPS run linux") I just have some basic …

Member Avatar for nezachem
0
156
Member Avatar for mrnutty

Frankly, I did not understand the statement of the problem. The more I read it the more contradictory it looks. Maybe I shall quit drinking. Can you please translate the following [QUOTE]A multiplied Sum Of digits is the sum of the digits of a number N, in which those those …

Member Avatar for mrnutty
0
148
Member Avatar for Pamilerin

[QUOTE]Value = a0 * x^ 0 + a1 * x ^1 + .... + aN * x^n , run through the array and compute the result. [/QUOTE] Just as NB, don't do it directly as written, it is highly inefficient. a0 + x*(a1 + x*(a2 + ... +x*(a[N-1] + x*aN)))))...))) …

Member Avatar for nezachem
0
100
Member Avatar for ivanhny

Use a debugger. Set a breakpoint at line 122. Run. Initialize your tree with 1, 2 and 3. Step few times, enter 4 when prompted. Step, step, step up to line 129. Step again. Get surprised. Ask yourself how it is possible to get where it gets you. Solve the …

Member Avatar for DanielGreen
0
95
Member Avatar for ROTC89
Member Avatar for grib

In your second listing (function definitions) the functions you define do not belong to any namespace. [icode]using namespace SALES;[/icode] merely informs the compiler to decorate referred names. You should put them in a namespace the same way you did in the header file, that is inside [icode]namespace SALES {...}[/icode]

Member Avatar for grib
0
270
Member Avatar for johndoe444

[QUOTE][CODE]#include "abc.c"[/CODE][/QUOTE] doesn't go together with [QUOTE]abc.c is only available as abc.o (source code not available)[/QUOTE] Did you mean to #include "abc.h" perchance? abc.h should contain [CODE]extern int a;[/CODE] Don't forget to delete line 3 in your test-lib.c

Member Avatar for nezachem
0
110
Member Avatar for matthewl

The End.