- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
18 Posted Topics
[CODE]myuser@linux:~/Desktop$ gcc -nostdlib -Wl,-dynamic-linker,/home/myuser/Desktop/ld-linux-x86-64.so.2,-rpath,/home/myuser/Desktop libc.so.6 libgcc_s.so.1 simple.c myuser@linux:~/Desktop$ ldd a.out linux-vdso.so.1 => (0x00007fffbf5ff000) libc.so.6 => /home/myuser/Desktop/libc.so.6 (0x00007f308b7ae000) libgcc_s.so.1 => /home/myuser/Desktop/libgcc_s.so.1 (0x00007f308b598000) /home/myuser/Desktop/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f308bb11000) myuser@linux:~/Desktop$ [/CODE] Which ld is being used, the one on the Desktop or the one in /lib64 ? What options do I have to use … | |
The prototype for setsockopt is: [CODE]int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len);[/CODE] Are the following all correct ? Which are not ? [CODE]int buffsize = 50000; setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&buffsize, sizeof(buffsize));[/CODE] [CODE]int buffsize = 50000; setsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *)&buffsize, sizeof(buffsize));[/CODE] [CODE]char *buffsize = … | |
N00B here. I need to reuse a function's return in other functions. The problem is that the function's return changes every time it is called. How to achieve this? [CODE]int FUNCTION1(void) { // do stuff return FUNCTIONRESULT; // return to be reused in other functions } int FUNCTION2(void) // <- … | |
I need to generate and reuse a 5 digit random number every time my program is executed. But the following generates random numbers every time the function is called. [CODE]#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include <time.h> int RANDOM(void) { int RANDOMNUMBER = 0; srand((unsigned int)time(NULL)); … | |
I'm trying to make a simple search script but cannot get it right. The script should search for keywords inside files. Then return the file paths in a variable. (Each file path separated with \n). [CODE]#!/bin/bash SEARCHQUERY="searchword1 searchword2 searchword3"; for WORD in $SEARCHQUERY do GREPINPUT=$GREPINPUT" | grep --ignore-case --files-with-matches -e … | |
I get this g++ warning when I use the [I]-Wconversion[/I] flag. Anybody know how to write this "correctly" ? [QUOTE]a.cpp:15: warning: conversion to ‘float’ alters ‘double’ constant value[/QUOTE] [CODE]#include <iostream> using namespace std; float VAR1(float VAR2) { int VAR3 = (int)(VAR2 * 1.045 * 1.55); // Result must be an … | |
I get this gcc warning with [I]-Wwrite-strings[/I] flag. I want to return a string of chars correctly but I also do not want to use [I]malloc[/I]. I've read other posts but can somebody explain how to acheive this in layman wording? [QUOTE]a.c:14: warning: passing argument 1 of ‘VAR1’ discards qualifiers … | |
How can I return the file modification time as an int (UNIX epoch)? [CODE]#include <time.h> #include <sys/stat.h> int *FILEMOD(char *FILENAME) { struct stat ATTRIBUTES; time_t MTIME; stat(FILENAME, &ATTRIBUTES); MTIME = ATTRIBUTES.st_mtime; return MTIME; } int main(void) { printf("%i",FILEMOD("file.txt")); return 0; }[/CODE] gcc errors: [ICODE]filemod.c: In function ‘FILEMOD’: mod.c:14: warning: return … | |
My website is programmed in PHP and currently uses HTTP compression (gzip) using PHP's built-in compression functions. (I cannot use mod_deflate.c because my shared hosting provider will not install it because it would use a lot of CPU.) The shared server where my website is hosted currently hosts 100 other … | |
N00B. If I compile a simple Hello World! program on a 64bit linux, will it work on a 32bit linux? (I'm using gcc). [CODE]#include <stdio.h> int main(void) { printf("Hello World!"); return 0; }[/CODE] | |
How to: 1. Buffer output ? 2. Get its size ? 3. Print the buffer ? [CODE]#include <stdio.h> int main(void) { printf("Tons of printf lines\n"); // 1. Somehow buffer the output up until this point printf("The size of the buffer is: %i\n", SIZEOFBUFFER); // 2. Get and print the size … | |
N00B. I keep getting a segmentation fault when I try to substitute a word with another. I'm using this tutorial as an example but don't seem to get it right: [url]http://www.cplusplus.com/reference/clibrary/cstring/strstr/[/url] [CODE]#include <stdio.h> #include <string.h> void REPLACE(char STRING[]) { char *MONTH[] = {"January","February","March","April","May","June","July","August","September","October","November","December"}; char *MES[] = {"Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"}; int B = … | |
How can the webpage that is downloaded be stored inside a variable? [CODE]#include <iostream> #include <cstdlib> using namespace std; int main(void) { int VAR = system("wget http://www.google.com"); return 0; }[/CODE] | |
Does C++ wait for a *system* shell command to finish before executing the rest of the C++ code? (The shell script does not output any text, it simply executes *find* to *rm* files.) I'm saying this because the shell script [U]may[/U] take a long time to find and delete all … | |
1. How can I check if a variable has been initialized (if it exists). 2. How can I check if a variable is empty (if the variables contains data). I'm using g++. | |
N00B. Is it possible to compile every line in a file except one? That line would be left in text mode inside the compiled file. Would the file even execute? I'm using gcc (g++). | |
N00B. Can I buffer cout, cout something and then cout the buffer? I've been googleing but did not find anything of this sort. [CODE]#include <iostream> using namespace std; int main (void) { cout << "cout output until this point"; string BUFFER; // I need to buffer the cout output until … | |
N00B. I cannot seem to get this right. [CODE]#include <iostream> #include <cstdlib> using namespace std; int main(void) { system(("sendmail -options" + EMAIL_TEXT)); return 0; }[/CODE] |
The End.