Add the line
cout << "fact = " << fact << endl;
right after line 24, and see what happens.
Add the line
cout << "fact = " << fact << endl;
right after line 24, and see what happens.
The Ubuntu version does not match the original. For example, -L/usr/local/difmap2.4k/lib -lsphere
has different meaning than -L/usr/local/uvf_difmap/lib/libsphere
Try this:
g++-4.5 -o splitc splitc.o -L/usr/local/uvf_difmap/lib/ -L/usr/lib/x86_64-linux-gnu -lsphere -llogio -lpager -lcpgplot -lpng -lpgplot --lX11 -lfits -lrecio -lscrfil -lslalib -ltecla -lcurses /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5/libgcc.a
As of what to do with the build script, make sure it has executable permissions, and just type its name at the command line.
Most of the linux development is driven by commercial enterprises. Linux is a great vehicle to sell the hardware to OEMs, be it in form of an evaluation kit or a reference design.
Every hardware designer wants linux to run on their platform; usually up to 10% of the software budget of such lab goes to linux development (both kernel, and dev tools). And yes, the development is done by paid employees. Most of the efforts are to support a particular product, still a lot ends up in a mainline.
It is funny to see how linux makes competitors to collaborate.
0. The installer makes end users comfortable.
1. An end user is more or less sure that the thing she installs is what it claims to be. See bullet 0.
2. Most applications need third party libraries, drivers, services, registry settings, and whatnot (not to mention previous versions and cross-version compatibility). Most of the times these prerequisites contradict the target system's setup, and have to be resolved. The installer takes care on the issue (or at least it prevents the catastrophe). See bullet 0.
3. The installer knows - and records - what's been installed, which makes possible to undo the installation. See bullet 0.
4. I might forget other reasons. What's important is bullet 0.
I actually want to automatically add .c and .o files whenever i create a new .c files.
Umm... there is a way, read on the wildcard function and stem substitution, as in
SOURCES := $(wildcard *.c)
OBJECTS := $(SOURCES: %.c=%.o)
calc: $(OBJECTS)
gcc -o calc $(OBJECTS)
%.o: %.c
gcc -c $< -o $@
In my opinion, wildcard is a misfeature (if you wish I may elaborate). In any case do not try to use it until you comfortably understand the basic make functionality.
Make's way of thinking is sort of convoluted. Take small steps to get used to it.
can anybody explain what the variables $@ and $< mean.
$@ in a recipe means a target name. For example,
foo.o: foo.c
gcc -o foo.o foo.c
is the same as
foo.o: foo.c
gcc -o $@ foo.c
Similarly, $< means a prerequisite name:
foo.o: foo.c
gcc -o $@ $<
Not much of a value for the explicit rules, but very useful for the stem rules, such as
%.o: %.c
gcc -o $@ $<
It is a very bad habit to use an asterisk in the dependency. Consider the situation:
foo.c bar.c are the sources. For some reason foo has been compiled into foo.o, but bar.c was not. The directory contains foo.c, bar.c, and foo.o. The dependency *.o at line 4 in your makefile evaluates to just foo.o so bar.c is never compiled.
The solution is to spell your object files explicitly:
objects = foo.o bar.o baz.o
calc: $(objects)
gcc -o calc $(objects)
There are advanced techniques, but for now do spell your objects out.
What is my program thinking?
I have no idea. You need to debug. For that, I'd recommend to provide an ability to call evaluate() directly with any given position. Call it with
XXO
-O-
-X-
and
XXO
-O-
X--
See which one gets better score. If the first one scores better, the error is in evaluate(). Trace its execution line by line. Otherwise, the error is in alpha-beta. Again, trace why the better scoring position gets rejected.
X--
---
--- Perfect 1st move for Tic Tac Toe!
To begin with, I wouldn't call it perfect.
Now, if you are sure that the alpha-beta works correctly (I didn't bother to check), then the problem must be in a statical evaluation. And it is there indeed. Hint: pay attention to the compiler warnings.
Is there another way I am not considering?
> gcc -c foo.c
> gcc -c bar.c
> gcc -o baz foo.o bar.o
>
Of course an object file can be linked. In fact, only the object files are linked.
A library is a convenient way to package a collection of objects. They are not linked directly. The linker extracts required objects from the library and links them.
Does anyone have any ideas?
Of course. Assigning a pointer does not copy the string contents:
g_ppRecords[g_numRecords]->firstName =(char*) malloc(sizeof(token));
g_ppRecords[g_numRecords]->firstName = token;
Now firstName points to token, not the memory you've allocated. That is, firstName in every record points somewhere into the input array, and most likely to the exact same place.
First of all, explain the loops
for (Y=y1; y2!=Y ;Y++){
at lines 110 and 144. I am asking because the loop parameter Y is not used in the loop body.
Second, (re)read an article on a Bresenham algorithm until you understand completely how it works.
You calculate the position of the new environment variable (line 81) based on the length of the current one. It is OK as long as you use the original length. In case of PATH it is not so.
Yes.
At lines 23, 30 and 34 the behavior is undefined. The improvement is obvious.
so - there's no way to stop comparison thread safely using signals ?
No. The pthread_create man page explicitly says that
The set of pending signals for the new thread is empty
I need perform all operations in such order as in list
This sort of defeats the purpose of multithreading...
this situation needs that at least the third thread will be stoped just after creation
A semaphore or a conditional variable would do it much better.
I don't think it is possible. What exactly are you trying to achieve? I mean, is using signals a requirement?
skip 16bit it is dead
I wouldn't be so definite. 16-bit is very well around (and, ugh, 8-bit too). Their niches are very specific indeed, but really, 8-bit is the only area where assembly programming skills still have value.
The problem is that a Weierstrass product converges very poorly (my gut feeling is that it is worse than linear; correct me if I am wrong). That is, even 1e8 iterations may not be enough.
Like passing j++ and k++ etc?
Yes. Expressions a and b are evaluated twice. So the side effect (if any) happens twice (which is already unhealthy), and may lead to an undefined behaviour.
#define
is a textual substitution. The expression expands to
i < j > k? j: k
I leave it as an exercise to figure out the actual precedence. To avoid such mess, you need to be more explicit:
#define max( a, b) (a > b ? a:b)
Notice an extra pair of parenthesis.
PS: even now the macro poses a number of problems.
Well something must be different. My first recommendation is to attach a debugger, and figure out what exactly is failing. My second recommendation is to get rid of system(), and use rename() and unlink(); if you insist on system(), at least spell out explicit paths to mv and rm.
thanks for reply nezachem.
I'm very newbee (actually just starting) with code analysis so take my words with grain of salt! that being said, let say I want to get a class from PHP file and all its Childrens (members as well as attributes) and thereby build a tree I can access. How do I go about?
Feed the PHP code you want to analyze to yyparse(). That would build the tree (unfortunately, you'd be stuck with a global variable to build the tree from; that's a vary annoying shortcoming of bison).
Sorry if I misunderstood the question.
Should I write a new grammar file or just use this one from zend?
I do not know how authoritative is Zend (I am pretty far from the PHP world). If you trust it to reliably represent the grammar, then, by all means, use it. Of course, all the zend_* functions shall be tailored for your needs.
Define a generic node type; somewhat akin to
typedef struct node_s {
enum node_type_t node_type;
void * node_specific_data;
node_s ** children;
} node_t;
You may need other fields as well.
Define "node constructors" for each language entity (terminals and nonterminals alike).
In the semantic action for each rule, call a relevant constructor, assign it to $$
, allocate the children array, and fill it up with pointers to child nodes, available as $1, $2
etc.
That's pretty much it. As soon as you have a grammar, this process is almost mechanical.
PS: tutorial
So, you passed FunctionToPass to ThreadProc as a parameter, which is correct. Now you need to actually call it:
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
void (* function)() = (void (*)())lpParameter;
function();
return 0;
}
void not ignored as it ought to be
because you are not passing the function to the thread. You are calling it (notice ()
in FunctionToPass()
at line 21), then try to dereference the result (notice *
there). Since FunctionToPass is void, the compiler complains.
a bunch of preceding syntax errors
They are probably much more relevant. Start with the first one.
PS: I bet you are missing a semicolon somewhere in one of your .h files.
In this context, lemma is a dictionary form of a word.
Wrong. Reaching end of file is not an error.
That was not what I meant. In my own opinion, the OP meant that a user-defined function can run AFTER main() has ended, of which I try to explain that if main() has ended, the program has ended.
Even that is wrong. Add a
~foo() { std::cout << "Me last!!" << std::endl; }
to Narue's example.
Why do you need test? Read directly to where you want it to be. Of course, you can also memcpy(name[i], test.name, sizeof(test.name))
.
Newton-Raphson, of course. I expect you already implemented addition and division.
The problem with signal is that there's not much you can do in a handler. The list of signal-safe functions is quite limited (man 7 signal), and printf is not one of them. I don't know what exactly your sql querying involves, but the gut feeling says that signal handler is not a right place.
The code breaks the loop when ftell(p) returns -1. At what circumstances do you expect this to happen?
Since the thread appears in the C forum, I can't recommend boost::asio (and I didn't). Depending on which platform you are targeting, you may look at the IO completion ports, WaitForMultipleObject(), [e]poll(), or select().
The latter is really the largest common denominator of all IO muxing techniques; it is somewhat cumbersome, it may lead to a seriously inefficient system, it may even be misused to non-portability. However, in my opinion, it is the best starting point for applications such as yours.
The problem is that data
is one-element array. The only valid element is data[0]
. Accessing data[1]
is illegal. Try data[0] = whatever
.
Still, we need to see the code which produces error.
The presence of flags, and special casing of certain conditions usually indicate that something is wrong. For example, on a very first insertion you compare temp with arr[0], which has a garbage value. If that comparison fail, the next comparison accesses arr[count], and count is -1. Welcome undefined behaviour.
Looking closely, you'd realize that all the work is really done in lines 32-42, with small modifications (count shall be initialized to 0 BTW):
for(pos = 0; (pos < count) && (temp > arr[pos]); pos++)
;
for(i = count; i > pos; i--)
arr[i] = arr[i - 1];
arr[pos] = temp;
count++;
Make sure you understand why count must be initialized to 0, and how your special cases are automatically handled here.
> But, when I try to define data in another line of code, I get cross-type errors.
Can you show how you do it?
it says the the length of the string is 14h
src DB 'abcdefghi$' dst DB 10 dup(0) len DB EQU $-src
Yes, that's exactly what should happen.
A $ sign at the line 3 is an assembly pointer, and its goal is to trace addresses at which the code is currently assembled. When assembler start processing a directive at line 1, that is when it encounters the src label, $ and src have the same value. When assembler is done with line 1, that is after it allocated 10 bytes, $ increases by 10. After assembler is done with line 2, $ is increased one more time by the amount allocated there, and becomes src + 10 + 10. At line 3, a $-src expression obviously yields 20.
Don't confuse the assembly pointer with the '$' in your src.
man strftime. The format string you need is "%Y-%m-%d %H:%M:%S".
Correct me if I am wrong, but for me HTTP Version Not Supported means exactly what it says: HTTP version (1.1 in your case) is not supported. Try HTTP/1.0 instead.
It means the variable "extra" is equal to the number in array cell 20.
The long way is: extra = extra + randomArray[20]
These two explanations are sort of contradictory. So, is it equal, or is it increased by?
So back to base 1, can you explain the plus sign. And I don't mean syntax. I mean, why did you put it there?
Can you explain the plus sign at line 18?
There's a bunch of issues with the code.
1. An argument DevicePath of DisplayVolumePaths shadows the global DevicePath.
2. You are printing DevicePath[1] regardless of how many paths has been found.
3. Most important problem: DevicePath is populated with pointers to memory which is deleted at line 60.
Of course it is declared. How it is initialized mean how does it receive its initial value. So, where in your code filesize gets initialized?
When your server starts sending a large file (line 195) it stops paying attention to incoming data, until the file is completely transmitted. Its incoming buffer fills up. After that, the client can't send anything and gets stuck at line 90. The server keeps sending. Client's buffer fills up. Now both are stuck.
You need to seriously rethink the server design.
PS: I am not familiar with DDC spec, but TCP and packets do not go together. Seems like you are missing something.
PPS:
}while(count < filesize);
How does filesize
gets initialized?
> i need to check there is at least one factor between the numbers before i call the gcd method on them.
No. You need to fix the gcd code. Hint: any two numbers have a common factor 1.