2-opt algorithm for traveling salesman problem in C programming
Hello Can someone give me a code sample of 2-opt algorithm for traveling salesman problem in C programming.. ...
Hello Can someone give me a code sample of 2-opt algorithm for traveling salesman problem in C programming.. ...
Hi im trying to read data from pipe using poll, here is code: #include <stdio.h> #include <fcntl.h> #include <poll.h> #define MAX_BUFF_SIZE 128 int main(void){ char buff[MAX_BUFF_SIZE]; char *buf; int fd,ret,len; struct pollfd fdinfo[1]; if((fd = open("/home/s/pipe", O_RDONLY)) == NULL) { printf("Error Ope...
How do I cause a thread to respond to pthread_cancel() if it is blocked on a sem_wait()? ...
source code for program in c language to manage the working of a construction company. Implement and manage the records with suitable data structures of company and their states(proposal, installation, maintenance, yearly contract etc.), the business turnovers of company, salaries of employees, present assignments of employees and detai...
Apple sometimes uses the Bitwise-Shift operator in their enum definitions. For example, in the CGDirectDisplay.h file which is part of Core Graphics: enum { kCGDisplayBeginConfigurationFlag = (1 << 0), kCGDisplayMovedFlag = (1 << 1), kCGDisplaySetMainFlag = (1 << 2), kCGDisplaySetModeFlag = (1 << 3), ...
Lets say I have the following in C struct address{ char name; int id; char address; }; struct address adrs[40]; //Create arbitrary array of the structure. 40 is example adrs[0].name = 'a'; id[0] = 1; ... What is the equivalent way of defining and creating array of a user defined structure. Thanks ...
During a recent discussion (see comments to this answer), R.. recommended to never create aliases for pointer-to-const types as you won't be able to deallocate the referenced objects easily in a conforming C program (remember: free() takes a non-const pointer argument and C99 6.3.2.3 only allows conversions from non-qualified to qualifi...
I have a C source file having comments in // (C++) style. I want to change all the comments to the old /* */ (C) style. Is there a way to do this using an existing script? ...
I have added some UIButton in scrollveiw and linked it up with page control but when I tap my button so my pages control automatically scroll to page 1 which is initial page. So how can I erradicate this problem. After TouchUp inside event it comes in this delegate function - (void) scrollViewDidScroll: (UIScrollView *) aScrollView and...
Hello, I have always been taught almost never to use goto statements in programming, however we are required to do so as part of my most recent programming project. I have an if/else statement with various goto statements, and the goto statements are failing to execute. I have no idea why. Any help would be appreciated. int myInt...
So I'm just tinkering around with C and wanted to see if I could assign a binary value to an integer and use the printf() function to output either a signed or unsigned value. But regardless I get the same output, I thought I'd get half the value for printing the signed compared to the unsigned. I'm using Code::blocks and GCC. Does pr...
Hi there, a malloc question. First, I generate some strings. And second, I allocate none-space for copying pointers which point to those strings. At this moment the program should probably crash, since I ve tried to copy those pointers to nowhere, but it doesn’t crash. How is it possible? Any comments would be appreciated. #include <...
#include<stdio.h> int main(void) { char c = 0x80; printf("%d\n", c << 1); return 0; } The output is -256 in this case. If I write c << 0 then the output is -128. I don't understand the logic behind this code. ...
i have one text file that contains only one line the line only contains one math expression for example 12+(3.0*(4)-1)/sqrt(121) my program needs to read this express as string and then give the result 13 is there any simple way or 3rd party dll/lib to make this out? COMMENT ADDED: http://stackoverflow.com/questions/928563/code-golf...
#include <stdio.h> int main(void) { int x = 1000; char *ptr = &x; printf("%d\n",*ptr); return 0; } Output: -24 /*In gcc 4.4.3 in Ubuntu 10.04 OS*/ With a warning: initialization from incompatible pointer type What I think if the base type of the pointer were of int type then it would have retrieved 4 bytes from the ...
In the following code is is guaranteed that "0\n" be printed? #include <stdio.h> int main(void) { int c = 0; printf("%d\n",c); printf("%d,%d\n",++c,++c); } More generally, if a program has undefined behavior does the entire program become undefined or only from the sequence point that begins the problematic code? Please...
I currently have a C function that I'd like to use in .NET (C#). I can see two ways of achieving this: Compiling it (I think this is possible) with /clr on VC++.NET, having implemented "façade" managed methods that call the C code. Compiling the C code as a DLL and then making API calls. What do you find best? How to do the first of...
Hi, I am a new developer of C++ and i want to do socket programming in c++ or VC++.net. If you have good and easy to learn tutorial for socket programming in c/c++ please share the link. ...
Hi! I'm trying to create a simple remote management program where a user can connect to my little device and "take over" the current stdio of the system. For example: System boots with console=serial port --> client connects, redirect input/output to the socket I have already accomplished the redirection to network part (by reading th...
#include<stdio.h> int main() { double fract=0; int tmp; //scanf("%lf",&fract); fract=0.312; printf("%lf",fract); printf("\n\n"); while(fract>0){ fract*=(double)10; printf("%d ",(int)fract); fract-=(int)fract; } getch(); return 0; } this code shoud have an output of: 312 ...