Linked Questions

17 votes
3 answers
13k views

I need to optimize some for loops for speed (for a school assignment) without using compiler optimization flags. Given a specific Linux server (owned by the school), a satisfactory improvement is to ...
Black Dahlia1147's user avatar
51 votes
2 answers
6k views

Many methods found in high-performance algorithms could be (and are) simplified if they were allowed to read a small amount past the end of input buffers. Here, "small amount" generally ...
BeeOnRope's user avatar
  • 66.3k
3 votes
5 answers
69k views

I am compiling with: gcc 4.7.2 c89 I have the macro: #define LOG_ERR(fmt, ...) \ fprintf(stderr, "[ERROR] %s:%d: error [%s] " fmt "\n&...
ant2009's user avatar
  • 22.7k
2 votes
5 answers
8k views

I want to concatenate two strings which are defined like this: char hello[] = { 'H', 'e', 'l', 'l', 'o', '\0' }; char world[] = { ',', ' ', 'W', 'o', 'r', 'l', 'd', '!', '\0' }; I understand that I ...
Viacheslav Kondratiuk's user avatar
0 votes
9 answers
9k views

I am working with the const char * type in C. Due to the libraries I am using I am trying not to use or include other libraries (namely cstring). The function I am working in is passed a buffer of ...
user749681's user avatar
0 votes
5 answers
837 views

If i want to concatenate 2 strings in C, do i have to allocate an extra null char for every string or one is enough? int main(){ char *s1 = NULL; char *s2 = NULL; char *s1_s2 = NULL; ...
Vlad Balmos's user avatar
  • 3,412
1 vote
2 answers
2k views

How would I make a GCC C program on Linux that: has a PHP program script inside itself, not as a separate file expands itself out to /tmp shells out to php CLI command line to run the PHP script ...
Volomike's user avatar
  • 25k
0 votes
2 answers
874 views

I'm trying to parse argv back into a single string to use for a system call. The string shows up fine through the printf call (even without the \0 terminator), but using it as a parameter to system ...
aelgoa's user avatar
  • 1,201
0 votes
1 answer
1k views

Function which worked previously, suddenly refuses cooperation. More precisely this snippet: //If not, add to UIDS printf("line 78\n"); free(s2); printf("line 82\n"); char * ss = ...
Xyzk's user avatar
  • 1,342
1 vote
2 answers
196 views

Whenever I run my code I get through 4 iterations of reading the file and creating a pthread until it segfaults with ID 11. The segfault is caused by my print ln: printf("%s %s\n", "Calling ...
coloradocoder's user avatar
1 vote
3 answers
198 views

I have the bellow bit of code that works just fine. FILE *pipe_fp; if((pipe_fp = popen("php", "w")) == NULL) { perror("popen(PHP)"); exit(1); } fputs("<?php echo process('xx'); ?&...
transilvlad's user avatar
  • 14.6k