Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Transform the following Go implementation into C, maintaining the same output and logic.
package main import ( "github.com/gotk3/gotk3/gtk" "log" "math/rand" "strconv" "time" ) func validateInput(window *gtk.Window, str string) (int64, bool) { i, err := strconv.ParseInt(str, 10, 64) if err != nil { dialog := gtk.MessageDialogNew( window, gtk.DIA...
#include <windows.h> #include "resource.h" BOOL CALLBACK DlgProc( HWND hwnd, UINT msg, WPARAM wPar, LPARAM lPar ) { switch( msg ) { case WM_INITDIALOG: srand( GetTickCount() ); SetDlgItemInt( hwnd, IDC_INPUT, 0, FALSE ); break; case WM_COMMAND: swit...
Convert the following code from Go to C, ensuring the logic remains intact.
package main import ( "github.com/gotk3/gotk3/gtk" "log" "math/rand" "strconv" "time" ) func validateInput(window *gtk.Window, str string) (int64, bool) { i, err := strconv.ParseInt(str, 10, 64) if err != nil { dialog := gtk.MessageDialogNew( window, gtk.DIA...
#include <windows.h> #include "resource.h" BOOL CALLBACK DlgProc( HWND hwnd, UINT msg, WPARAM wPar, LPARAM lPar ) { switch( msg ) { case WM_INITDIALOG: srand( GetTickCount() ); SetDlgItemInt( hwnd, IDC_INPUT, 0, FALSE ); break; case WM_COMMAND: swit...
Preserve the algorithm and functionality while converting the code from Go to C.
package main import ( "bufio" "fmt" "io" "math/rand" "time" ) func choseLineRandomly(r io.Reader) (s string, ln int, err error) { br := bufio.NewReader(r) s, err = br.ReadString('\n') if err != nil { return } ln = 1 lnLast := 1. var sLast string for { ...
#include <stdio.h> #include <stdlib.h> inline int irand(int n) { int r, randmax = RAND_MAX/n * n; while ((r = rand()) >= randmax); return r / (randmax / n); } inline int one_of_n(int n) { int i, r = 0; for (i = 1; i < n; i++) if (!irand(i + 1)) r = i; return r; } int main(void) { int i, r[10] = {0}; for (i ...
Change the following Go code into C without altering its purpose.
package main import ( "bufio" "fmt" "io" "math/rand" "time" ) func choseLineRandomly(r io.Reader) (s string, ln int, err error) { br := bufio.NewReader(r) s, err = br.ReadString('\n') if err != nil { return } ln = 1 lnLast := 1. var sLast string for { ...
#include <stdio.h> #include <stdlib.h> inline int irand(int n) { int r, randmax = RAND_MAX/n * n; while ((r = rand()) >= randmax); return r / (randmax / n); } inline int one_of_n(int n) { int i, r = 0; for (i = 1; i < n; i++) if (!irand(i + 1)) r = i; return r; } int main(void) { int i, r[10] = {0}; for (i ...
Please provide an equivalent version of this Go code in C.
package main import ( "fmt" "strconv" ) func main() { var maxLen int var seqMaxLen [][]string for n := 1; n < 1e6; n++ { switch s := seq(n); { case len(s) == maxLen: seqMaxLen = append(seqMaxLen, s) case len(s) > maxLen: maxLen = len(s) s...
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct rec_t rec_t; struct rec_t { int depth; rec_t * p[10]; }; rec_t root = {0, {0}}; #define USE_POOL_ALLOC #ifdef USE_POOL_ALLOC rec_t *tail = 0, *head = 0; #define POOL_SIZE (1 << 20) inline rec_t *new_rec() { if (head == tail) { head = cal...
Maintain the same structure and functionality when rewriting this code in C.
import ( "fmt" "strings" ) func main() { for _, n := range []int64{ 1, 2, 3, 4, 5, 11, 65, 100, 101, 272, 23456, 8007006005004003, } { fmt.Println(sayOrdinal(n)) } } var irregularOrdinals = map[string]string{ "one": "first", "two": "second", "three": "third", "five": "fifth", "eight": "eighth"...
#include <stdbool.h> #include <stdio.h> #include <stdint.h> #include <glib.h> typedef uint64_t integer; typedef struct number_names_tag { const char* cardinal; const char* ordinal; } number_names; const number_names small[] = { { "zero", "zeroth" }, { "one", "first" }, { "two", "second" }, { "three",...
Transform the following Go implementation into C, maintaining the same output and logic.
package main import ( "fmt" "strconv" "strings" ) func sdn(n int64) bool { if n >= 1e10 { return false } s := strconv.FormatInt(n, 10) for d, p := range s { if int(p)-'0' != strings.Count(s, strconv.Itoa(d)) { return false } } return true } fu...
#include <stdio.h> inline int self_desc(unsigned long long xx) { register unsigned int d, x; unsigned char cnt[10] = {0}, dig[10] = {0}; for (d = 0; xx > ~0U; xx /= 10) cnt[ dig[d++] = xx % 10 ]++; for (x = xx; x; x /= 10) cnt[ dig[d++] = x % 10 ]++; while(d-- && dig[x++] == cnt[d]); return d == -1; ...
Change the programming language of this snippet from Go to C without modifying what it does.
package main import ( "fmt" "strconv" "strings" ) func sdn(n int64) bool { if n >= 1e10 { return false } s := strconv.FormatInt(n, 10) for d, p := range s { if int(p)-'0' != strings.Count(s, strconv.Itoa(d)) { return false } } return true } fu...
#include <stdio.h> inline int self_desc(unsigned long long xx) { register unsigned int d, x; unsigned char cnt[10] = {0}, dig[10] = {0}; for (d = 0; xx > ~0U; xx /= 10) cnt[ dig[d++] = xx % 10 ]++; for (x = xx; x; x /= 10) cnt[ dig[d++] = x % 10 ]++; while(d-- && dig[x++] == cnt[d]); return d == -1; ...
Transform the following Go implementation into C, maintaining the same output and logic.
package main import "fmt" var example []int func reverse(s []int) { for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } } func checkSeq(pos, n, minLen int, seq []int) (int, int) { switch { case pos > minLen || seq[0] > n: return minLen, 0 case seq[0] == n:...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define TRUE 1 #define FALSE 0 typedef int bool; typedef struct { int x, y; } pair; int* example = NULL; int exampleLen = 0; void reverse(int s[], int len) { int i, j, t; for (i = 0, j = len - 1; i < j; ++i, --j) { t = s[i]; s[i...
Change the programming language of this snippet from Go to C without modifying what it does.
package main import "fmt" func main() { integers := []int{1_2_3, 0b1_0_1_0_1, 0xa_bc_d, 0o4_37, 0_43_7, 0x_beef} for _, integer := range integers { fmt.Printf("%d ", integer) } floats := []float64{1_2_3_4.2_5, 6.0_22e4, 0x_1.5p-2} for _, float := range floats { fmt.Printf("%g ", ...
#include <locale.h> #include <stdio.h> int main() { unsigned long long int trillion = 1000000000000; setlocale(LC_NUMERIC,""); printf("Locale : %s, One Trillion : %'llu\n", setlocale(LC_CTYPE,NULL),trillion); return 0; }
Write the same code in C as shown below in Go.
package main import "fmt" func main() { integers := []int{1_2_3, 0b1_0_1_0_1, 0xa_bc_d, 0o4_37, 0_43_7, 0x_beef} for _, integer := range integers { fmt.Printf("%d ", integer) } floats := []float64{1_2_3_4.2_5, 6.0_22e4, 0x_1.5p-2} for _, float := range floats { fmt.Printf("%g ", ...
#include <locale.h> #include <stdio.h> int main() { unsigned long long int trillion = 1000000000000; setlocale(LC_NUMERIC,""); printf("Locale : %s, One Trillion : %'llu\n", setlocale(LC_CTYPE,NULL),trillion); return 0; }
Write a version of this Go function in C with identical behavior.
package main import "fmt" func repeat(n int, f func()) { for i := 0; i < n; i++ { f() } } func fn() { fmt.Println("Example") } func main() { repeat(4, fn) }
#include <stdio.h> void repeat(void (*f)(void), unsigned int n) { while (n-->0) (*f)(); } void example() { printf("Example\n"); } int main(int argc, char *argv[]) { repeat(example, 4); return 0; }
Convert the following code from Go to C, ensuring the logic remains intact.
package main import "fmt" func repeat(n int, f func()) { for i := 0; i < n; i++ { f() } } func fn() { fmt.Println("Example") } func main() { repeat(4, fn) }
#include <stdio.h> void repeat(void (*f)(void), unsigned int n) { while (n-->0) (*f)(); } void example() { printf("Example\n"); } int main(int argc, char *argv[]) { repeat(example, 4); return 0; }
Ensure the translated C code behaves exactly like the original Go snippet.
package main import ( "bufio" "errors" "fmt" "math" "os" "regexp" "strconv" "strings" ) func main() { fmt.Println("Numbers please separated by space/commas:") sc := bufio.NewScanner(os.Stdin) sc.Scan() s, n, min, max, err := spark(sc.Text()) if err != nil { ...
#include<string.h> #include<stdlib.h> #include<locale.h> #include<stdio.h> #include<wchar.h> #include<math.h> int main(int argC,char* argV[]) { double* arr,min,max; char* str; int i,len; if(argC == 1) printf("Usage : %s <data points separated by spaces or commas>",argV[0]); else{ arr = (double*)malloc((argC-1...
Convert this Go snippet to C and keep its semantics consistent.
package main import ( "bufio" "errors" "fmt" "math" "os" "regexp" "strconv" "strings" ) func main() { fmt.Println("Numbers please separated by space/commas:") sc := bufio.NewScanner(os.Stdin) sc.Scan() s, n, min, max, err := spark(sc.Text()) if err != nil { ...
#include<string.h> #include<stdlib.h> #include<locale.h> #include<stdio.h> #include<wchar.h> #include<math.h> int main(int argC,char* argV[]) { double* arr,min,max; char* str; int i,len; if(argC == 1) printf("Usage : %s <data points separated by spaces or commas>",argV[0]); else{ arr = (double*)malloc((argC-1...
Convert this Go block to C, preserving its control flow and logic.
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) type NodeType int const ( ndIdent NodeType = iota ndString ndInteger ndSequence ndIf ndPrtc ndPrts ndPrti ndWhile ndAssign ndNegate ndNot ndMul ndDiv ndMod ndAd...
count = 1; n = 1; limit = 100; while (n < limit) { k=3; p=1; n=n+2; while ((k*k<=n) && (p)) { p=n/k*k!=n; k=k+2; } if (p) { print(n, " is prime\n"); count = count + 1; } } print("Total primes found: ", count, "\n");
Convert this Go block to C, preserving its control flow and logic.
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) type NodeType int const ( ndIdent NodeType = iota ndString ndInteger ndSequence ndIf ndPrtc ndPrts ndPrti ndWhile ndAssign ndNegate ndNot ndMul ndDiv ndMod ndAd...
count = 1; n = 1; limit = 100; while (n < limit) { k=3; p=1; n=n+2; while ((k*k<=n) && (p)) { p=n/k*k!=n; k=k+2; } if (p) { print(n, " is prime\n"); count = count + 1; } } print("Total primes found: ", count, "\n");
Preserve the algorithm and functionality while converting the code from Go to C.
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) type NodeType int const ( ndIdent NodeType = iota ndString ndInteger ndSequence ndIf ndPrtc ndPrts ndPrti ndWhile ndAssign ndNegate ndNot ndMul ndDiv ndMod ndAd...
count = 1; n = 1; limit = 100; while (n < limit) { k=3; p=1; n=n+2; while ((k*k<=n) && (p)) { p=n/k*k!=n; k=k+2; } if (p) { print(n, " is prime\n"); count = count + 1; } } print("Total primes found: ", count, "\n");
Transform the following Go implementation into C, maintaining the same output and logic.
package main import ( "fmt" "math/big" ) func main() { a := big.NewInt(42) m := big.NewInt(2017) k := new(big.Int).ModInverse(a, m) fmt.Println(k) }
#include <stdio.h> int mul_inv(int a, int b) { int b0 = b, t, q; int x0 = 0, x1 = 1; if (b == 1) return 1; while (a > 1) { q = a / b; t = b, b = a % b, a = t; t = x0, x0 = x1 - q * x0, x1 = t; } if (x1 < 0) x1 += b0; return x1; } int main(void) { printf("%d\n", mul_inv(42, 2017)); return 0; }
Produce a language-to-language conversion: from Go to C, same semantics.
package main import ( "fmt" "math/big" ) func main() { a := big.NewInt(42) m := big.NewInt(2017) k := new(big.Int).ModInverse(a, m) fmt.Println(k) }
#include <stdio.h> int mul_inv(int a, int b) { int b0 = b, t, q; int x0 = 0, x1 = 1; if (b == 1) return 1; while (a > 1) { q = a / b; t = b, b = a % b, a = t; t = x0, x0 = x1 - q * x0, x1 = t; } if (x1 < 0) x1 += b0; return x1; } int main(void) { printf("%d\n", mul_inv(42, 2017)); return 0; }
Preserve the algorithm and functionality while converting the code from Go to C.
package main import "github.com/go-vgo/robotgo" func main() { robotgo.MouseClick("left", false) robotgo.MouseClick("right", true) }
#define WINVER 0x500 #include<windows.h> int main() { int maxX = GetSystemMetrics(SM_CXSCREEN), maxY = GetSystemMetrics(SM_CYSCREEN); int x = maxX/2, y = maxY/2; double factorX = 65536.0 / maxX,factorY = 65536.0 / maxY; INPUT ip; ZeroMemory(&ip,sizeof(ip)); ip.type = INPUT_MOUSE; while(x > 5 || y < maxY...
Preserve the algorithm and functionality while converting the code from Go to C.
package main import "github.com/go-vgo/robotgo" func main() { robotgo.MouseClick("left", false) robotgo.MouseClick("right", true) }
#define WINVER 0x500 #include<windows.h> int main() { int maxX = GetSystemMetrics(SM_CXSCREEN), maxY = GetSystemMetrics(SM_CYSCREEN); int x = maxX/2, y = maxY/2; double factorX = 65536.0 / maxX,factorY = 65536.0 / maxY; INPUT ip; ZeroMemory(&ip,sizeof(ip)); ip.type = INPUT_MOUSE; while(x > 5 || y < maxY...
Write a version of this Go function in C with identical behavior.
package main import ( "fmt" "log" "net/http" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { fmt.Fprintln(w, "Goodbye, World!") }) log.Fatal(http.ListenAndServe(":8080", nil)) }
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> #include <err.h> char response[] = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html; charset=UTF-8\r\n\r\n" "<!DOCTYPE html><html><head><title>Bye-b...
Convert this Go snippet to C and keep its semantics consistent.
package main import ( "fmt" "log" "net/http" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { fmt.Fprintln(w, "Goodbye, World!") }) log.Fatal(http.ListenAndServe(":8080", nil)) }
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> #include <err.h> char response[] = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html; charset=UTF-8\r\n\r\n" "<!DOCTYPE html><html><head><title>Bye-b...
Convert this Go snippet to C and keep its semantics consistent.
package main import ( "github.com/fogleman/gg" "math" ) func main() { dc := gg.NewContext(400, 400) dc.SetRGB(1, 1, 1) dc.Clear() dc.SetRGB(0, 0, 1) c := (math.Sqrt(5) + 1) / 2 numberOfSeeds := 3000 for i := 0; i <= numberOfSeeds; i++ { fi := float64(i) fn := float6...
#include<graphics.h> #include<math.h> #define pi M_PI void sunflower(int winWidth, int winHeight, double diskRatio, int iter){ double factor = .5 + sqrt(1.25),r,theta; double x = winWidth/2.0, y = winHeight/2.0; double maxRad = pow(iter,factor)/iter; int i; setbkcolor(LIGHTBLUE); for(i=0;i<=iter;i++){ ...
Translate this program into C but keep the logic exactly as in Go.
#include <stdio.h> #include <limits.h> #define TRUE 1 #define FALSE 0 #define N_ROWS 5 #define N_COLS 5 typedef int bool; int supply[N_ROWS] = { 461, 277, 356, 488, 393 }; int demand[N_COLS] = { 278, 60, 461, 116, 1060 }; int costs[N_ROWS][N_COLS] = { { 46, 74, 9, 28, 99 }, { 12, 75, 6, 36, 48 }, ...
#include <stdio.h> #include <limits.h> #define TRUE 1 #define FALSE 0 #define N_ROWS 4 #define N_COLS 5 typedef int bool; int supply[N_ROWS] = { 50, 60, 50, 50 }; int demand[N_COLS] = { 30, 20, 70, 30, 60 }; int costs[N_ROWS][N_COLS] = { { 16, 16, 13, 22, 17 }, { 14, 14, 13, 19, 15 }, { 19, 19, 20, 23, ...
Rewrite the snippet below in C so it works the same as the original Go code.
package main import ( "fmt" "math" ) const ( RE = 6371000 DD = 0.001 FIN = 1e7 ) func rho(a float64) float64 { return math.Exp(-a / 8500) } func radians(degrees float64) float64 { return degrees * math.Pi / 180 } func height(a, z, d float64) float64 { aa := RE + a hh := ...
#include <math.h> #include <stdio.h> #define DEG 0.017453292519943295769236907684886127134 #define RE 6371000.0 #define DD 0.001 #define FIN 10000000.0 static double rho(double a) { return exp(-a / 8500.0); } static double height(double a, double z, double d) { double aa = RE + a; ...
Ensure the translated C code behaves exactly like the original Go snippet.
package main import ( "fmt" "math" ) type fps interface { extract(int) float64 } func one() fps { return &oneFps{} } func add(s1, s2 fps) fps { return &sum{s1: s1, s2: s2} } func sub(s1, s2 fps) fps { return &diff{s1: s1, s2: s2} } func mul(s1, s2 fps) fps { retur...
#include <stdio.h> #include <stdlib.h> #include <math.h> enum fps_type { FPS_CONST = 0, FPS_ADD, FPS_SUB, FPS_MUL, FPS_DIV, FPS_DERIV, FPS_INT, }; typedef struct fps_t *fps; typedef struct fps_t { int type; fps s1, s2; double a0; } fps_t...
Produce a functionally identical C code for the snippet given in Go.
package main import ( "fmt" "math" "rcu" ) func main() { powers := [10]int{0, 1, 4, 9, 16, 25, 36, 49, 64, 81} fmt.Println("Own digits power sums for N = 3 to 9 inclusive:") for n := 3; n < 10; n++ { for d := 2; d < 10; d++ { powers[d] *= d } i := int(math.P...
#include <stdio.h> #include <math.h> #define MAX_DIGITS 9 int digits[MAX_DIGITS]; void getDigits(int i) { int ix = 0; while (i > 0) { digits[ix++] = i % 10; i /= 10; } } int main() { int n, d, i, max, lastDigit, sum, dp; int powers[10] = {0, 1, 4, 9, 16, 25, 36, 49, 64, 81}; ...
Rewrite this program in C while keeping its functionality equivalent to the Go version.
package raster const b3Seg = 30 func (b *Bitmap) Bézier3(x1, y1, x2, y2, x3, y3, x4, y4 int, p Pixel) { var px, py [b3Seg + 1]int fx1, fy1 := float64(x1), float64(y1) fx2, fy2 := float64(x2), float64(y2) fx3, fy3 := float64(x3), float64(y3) fx4, fy4 := float64(x4), float64(y4) for i := range p...
void cubic_bezier( image img, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int x3, unsigned int y3, unsigned int x4, unsigned int y4, color_component r, color_component g, color_component b );
Keep all operations the same but rewrite the snippet in C.
package main import "fmt" func main() { list := pancake{31, 41, 59, 26, 53, 58, 97, 93, 23, 84} fmt.Println("unsorted:", list) list.sort() fmt.Println("sorted! ", list) } type pancake []int func (a pancake) sort() { for uns := len(a) - 1; uns > 0; uns-- { lx, lg := 0, a[0] ...
int pancake_sort(int *list, unsigned int length) { if(length<2) return 0; int i,a,max_num_pos,moves; moves=0; for(i=length;i>1;i--) { max_num_pos=0; for(a=0;a<i;a++) { if(list[a]>list[max_num_pos]) max_num_pos=a; } ...
Port the provided Go code into C while preserving the original functionality.
package main import ( "fmt" "math/rand" "rcu" "strings" "time" ) func main() { rand.Seed(time.Now().UnixNano()) var sb strings.Builder for i := 0; i < 1000; i++ { sb.WriteByte(byte(rand.Intn(10) + 48)) } number := sb.String() for i := 99999; i >= 0; i-- { qu...
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <time.h> #define DIGITS 1000 #define NUMSIZE 5 uint8_t randomDigit() { uint8_t d; do {d = rand() & 0xF;} while (d >= 10); return d; } int numberAt(uint8_t *d, int size) { int acc = 0; while (size--) acc = 10*acc + *d++; retur...
Can you help me rewrite this code in C instead of Go, keeping it the same logically?
package main import ( "fmt" "math/rand" "rcu" "strings" "time" ) func main() { rand.Seed(time.Now().UnixNano()) var sb strings.Builder for i := 0; i < 1000; i++ { sb.WriteByte(byte(rand.Intn(10) + 48)) } number := sb.String() for i := 99999; i >= 0; i-- { qu...
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <time.h> #define DIGITS 1000 #define NUMSIZE 5 uint8_t randomDigit() { uint8_t d; do {d = rand() & 0xF;} while (d >= 10); return d; } int numberAt(uint8_t *d, int size) { int acc = 0; while (size--) acc = 10*acc + *d++; retur...
Keep all operations the same but rewrite the snippet in C.
package main import ( "fmt" "rcu" ) func main() { for i := 1; i < 100; i++ { if !rcu.IsPrime(rcu.DigitSum(i*i, 10)) { continue } if rcu.IsPrime(rcu.DigitSum(i*i*i, 10)) { fmt.Printf("%d ", i) } } fmt.Println() }
#include <stdio.h> #include <stdbool.h> int digit_sum(int n) { int sum; for (sum = 0; n; n /= 10) sum += n % 10; return sum; } bool prime(int n) { if (n<4) return n>=2; for (int d=2; d*d <= n; d++) if (n%d == 0) return false; return true; } int main() { for (int i=1; i<100; i++) ...
Generate a C translation of this Go snippet without changing its computational steps.
package main import ( "fmt" "math" "rcu" "time" ) func sos(n int) []int { if n < 3 { return []int{} } var primes []int k := (n-3)/2 + 1 marked := make([]bool, k) limit := (int(math.Sqrt(float64(n)))-3)/2 + 1 for i := 0; i < limit; i++ { p := 2*i + 3 ...
#include <stdio.h> #include <stdlib.h> #include <math.h> int main(void) { int nprimes = 1000000; int nmax = ceil(nprimes*(log(nprimes)+log(log(nprimes))-0.9385)); int i, j, m, k; int *a; k = (nmax-2)/2; a = (int *)calloc(k + 1, sizeof(int)); for(i = 0; i <= k; i++)a[i] = 2*i...
Change the programming language of this snippet from Go to C without modifying what it does.
package main import ( "log" "github.com/jtblin/go-ldap-client" ) func main() { client := &ldap.LDAPClient{ Base: "dc=example,dc=com", Host: "ldap.example.com", Port: 389, UseSSL: false, BindDN: "uid=readonlyuser,ou=People,dc=examp...
#include <ldap.h> ... char *name, *password; ... LDAP *ld = ldap_init("ldap.somewhere.com", 389); ldap_simple_bind_s(ld, name, password); ... after done with it... ldap_unbind(ld);
Translate the given Go code snippet into C without altering its behavior.
package main import "fmt" func main() { lists := [][]int{ {9, 3, 3, 3, 2, 1, 7, 8, 5}, {5, 2, 9, 3, 3, 7, 8, 4, 1}, {1, 4, 3, 6, 7, 3, 8, 3, 2}, {1, 2, 3, 4, 5, 6, 7, 8, 9}, {4, 6, 8, 7, 2, 3, 3, 3, 1}, {3, 3, 3, 1, 2, 4, 5, 1, 3}, {0, 3, 3, 3, 3, 7, 2, 2, 6...
#include <stdio.h> #include <stdbool.h> bool three_3s(const int *items, size_t len) { int threes = 0; while (len--) if (*items++ == 3) if (threes<3) threes++; else return false; else if (threes != 0 && threes != 3) return false; return true; } void...
Translate this program into C but keep the logic exactly as in Go.
package permute func Iter(p []int) func() int { f := pf(len(p)) return func() int { return f(p) } } func pf(n int) func([]int) int { sign := 1 switch n { case 0, 1: return func([]int) (s int) { s = sign sign = 0 return } defa...
#include<stdlib.h> #include<string.h> #include<stdio.h> int flag = 1; void heapPermute(int n, int arr[],int arrLen){ int temp; int i; if(n==1){ printf("\n["); for(i=0;i<arrLen;i++) printf("%d,",arr[i]); printf("\b] Sign : %d",flag); flag*=-1; } else{ for(i=0;i<n-1;i++){ heapPermute(n-1,ar...
Generate an equivalent C version of this Go code.
package main import "rcu" func main() { var res []int for n := 1; n <= 70; n++ { m := 1 for rcu.DigitSum(m*n, 10) != n { m++ } res = append(res, m) } rcu.PrintTable(res, 7, 10, true) }
#include <stdio.h> unsigned digit_sum(unsigned n) { unsigned sum = 0; do { sum += n % 10; } while(n /= 10); return sum; } unsigned a131382(unsigned n) { unsigned m; for (m = 1; n != digit_sum(m*n); m++); return m; } int main() { unsigned n; for (n = 1; n <= 70; n++) { prin...
Convert this Go block to C, preserving its control flow and logic.
package main import "fmt" const ( N = 2200 N2 = N * N * 2 ) func main() { s := 3 var s1, s2 int var r [N + 1]bool var ab [N2 + 1]bool for a := 1; a <= N; a++ { a2 := a * a for b := a; b <= N; b++ { ab[a2 + b * b] = true } } for c := 1; ...
#include <stdio.h> #include <math.h> #include <string.h> #define N 2200 int main(int argc, char **argv){ int a,b,c,d; int r[N+1]; memset(r,0,sizeof(r)); for(a=1; a<=N; a++){ for(b=a; b<=N; b++){ int aabb; if(a&1 && b&1) continue; aabb=a*a + b*b; for(c=b; c<=N; c++){ int aabbcc=aabb +...
Convert this Go block to C, preserving its control flow and logic.
package main import "fmt" var d = [][]int{ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 0, 6, 7, 8, 9, 5}, {2, 3, 4, 0, 1, 7, 8, 9, 5, 6}, {3, 4, 0, 1, 2, 8, 9, 5, 6, 7}, {4, 0, 1, 2, 3, 9, 5, 6, 7, 8}, {5, 9, 8, 7, 6, 0, 4, 3, 2, 1}, {6, 5, 9, 8, 7, 1, 0, 4, 3, 2}, {7, 6, 5, 9, 8, 2, ...
#include <assert.h> #include <stdbool.h> #include <stdio.h> #include <string.h> static const int d[][10] = { {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 0, 6, 7, 8, 9, 5}, {2, 3, 4, 0, 1, 7, 8, 9, 5, 6}, {3, 4, 0, 1, 2, 8, 9, 5, 6, 7}, {4, 0, 1, 2, 3, 9, 5, 6, 7, 8}, {5, 9, 8, 7, 6, 0, 4, 3, 2, 1}, {6...
Rewrite the snippet below in C so it works the same as the original Go code.
package main import ( "fmt" "rcu" "strconv" "strings" ) func contains(list []int, s int) bool { for _, e := range list { if e == s { return true } } return false } func main() { fmt.Println("Steady squares under 10,000:") finalDigits := []int{1, 5, 6} ...
#include <stdio.h> #include <stdbool.h> bool steady(int n) { int mask = 1; for (int d = n; d != 0; d /= 10) mask *= 10; return (n * n) % mask == n; } int main() { for (int i = 1; i < 10000; i++) if (steady(i)) printf("%4d^2 = %8d\n", i, i * i); return 0; }
Maintain the same structure and functionality when rewriting this code in C.
package main import ( "fmt" "rcu" "strconv" ) func reverse(s string) string { chars := []rune(s) for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 { chars[i], chars[j] = chars[j], chars[i] } return string(chars) } func main() { fmt.Println("Numbers under 25,000 in base 10 wh...
#include <stdio.h> #define MAXIMUM 25000 int reverse(int n, int base) { int r; for (r = 0; n; n /= base) r = r*base + n%base; return r; } int palindrome(int n, int base) { return n == reverse(n, base); } int main() { int i, c = 0; for (i = 0; i < MAXIMUM; i++) { if (palin...
Produce a language-to-language conversion: from Go to C, same semantics.
package main import ( "fmt" "math/rand" "time" ) func main() { rand.Seed(time.Now().UnixNano()) totalSecs := 0 totalSteps := 0 fmt.Println("Seconds steps behind steps ahead") fmt.Println("------- ------------ -----------") for trial := 1; trial < 10000; trial++ { ...
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { int trial, secs_tot=0, steps_tot=0; int sbeh, slen, wiz, secs; time_t t; srand((unsigned) time(&t)); printf( "Seconds steps behind steps ahead\n" ); for( trial=1;trial<=10000;trial++ ...
Transform the following Go implementation into C, maintaining the same output and logic.
package main import "C" import "fmt" func main() { for i := 0; i < 80*25; i++ { fmt.Print("A") } fmt.Println() conOut := C.GetStdHandle(C.STD_OUTPUT_HANDLE) info := C.CONSOLE_SCREEN_BUFFER_INFO{} pos := C.COORD{} C.GetConsoleScreenBufferInfo(conOut, &info) pos.X = info.srWin...
#include <windows.h> #include <wchar.h> int main() { CONSOLE_SCREEN_BUFFER_INFO info; COORD pos; HANDLE conout; long len; wchar_t c; conout = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (conout == INVALID_HANDLE_VALUE) ...
Convert this Go snippet to C and keep its semantics consistent.
package main import "C" import "fmt" func main() { for i := 0; i < 80*25; i++ { fmt.Print("A") } fmt.Println() conOut := C.GetStdHandle(C.STD_OUTPUT_HANDLE) info := C.CONSOLE_SCREEN_BUFFER_INFO{} pos := C.COORD{} C.GetConsoleScreenBufferInfo(conOut, &info) pos.X = info.srWin...
#include <windows.h> #include <wchar.h> int main() { CONSOLE_SCREEN_BUFFER_INFO info; COORD pos; HANDLE conout; long len; wchar_t c; conout = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (conout == INVALID_HANDLE_VALUE) ...
Preserve the algorithm and functionality while converting the code from Go to C.
package main import "fmt" func random(seed int) int { return seed * seed / 1e3 % 1e6 } func main() { seed := 675248 for i := 1; i <= 5; i++ { seed = random(seed) fmt.Println(seed) } }
#include<stdio.h> long long seed; long long random(){ seed = seed * seed / 1000 % 1000000; return seed; } int main(){ seed = 675248; for(int i=1;i<=5;i++) printf("%lld\n",random()); return 0; }
Preserve the algorithm and functionality while converting the code from Go to C.
package main import ( "bufio" "fmt" "io" "log" "os" "strings" "unicode" ) type line struct { kind lineKind option string value string disabled bool } type lineKind int const ( _ lineKind = iota ignore parseError comment blank value ) func (l line) String() string { switch l.kind { cas...
#include <stdio.h> #include <stdlib.h> #include <string.h> #define strcomp(X, Y) strcasecmp(X, Y) struct option { const char *name, *value; int flag; }; struct option updlist[] = { { "NEEDSPEELING", NULL }, { "SEEDSREMOVED", "" }, { "NUMBEROFBANANAS", "1024" }, { "NUMBEROFSTRAWBERRIES", "62000" }, { NULL...
Convert this Go snippet to C and keep its semantics consistent.
package main import ( "fmt" "image" "image/color" "image/jpeg" "math" "os" ) func kf3(k *[9]float64, src, dst *image.Gray) { for y := src.Rect.Min.Y; y < src.Rect.Max.Y; y++ { for x := src.Rect.Min.X; x < src.Rect.Max.X; x++ { var sum float64 var i int ...
image filter(image img, double *K, int Ks, double, double);
Generate a C translation of this Go snippet without changing its computational steps.
package main import( "math" "fmt" ) func minOf(x, y uint) uint { if x < y { return x } return y } func throwDie(nSides, nDice, s uint, counts []uint) { if nDice == 0 { counts[s]++ return } for i := uint(1); i <= nSides; i++ { throwDie(nSides, nDice - 1,...
#include <stdio.h> #include <stdint.h> typedef uint32_t uint; typedef uint64_t ulong; ulong ipow(const uint x, const uint y) { ulong result = 1; for (uint i = 1; i <= y; i++) result *= x; return result; } uint min(const uint x, const uint y) { return (x < y) ? x : y; } void throw_die(const u...
Translate the given Go code snippet into C without altering its behavior.
package main import ( "encoding/xml" "fmt" "io" "net/http" "net/url" ) const language = "Go" var baseQuery = "http: "&format=xml&list=categorymembers&cmlimit=100" func req(u string, foundCm func(string)) string { resp, err := http.Get(u) if err != nil { fmt.Println(err) ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <curl/curl.h> #include "wren.h" struct MemoryStruct { char *memory; size_t size; }; static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *m...
Write a version of this Go function in C with identical behavior.
package main; import "fmt"; func main(){a, b := 0, 0; fmt.Println(a/b)}
int main(){int a=0, b=0, c=a/b;}
Convert this Go snippet to C and keep its semantics consistent.
package main import ( "image" "image/color" "image/gif" "log" "math" "os" ) func setBackgroundColor(img *image.Paletted, w, h int, ci uint8) { for x := 0; x < w; x++ { for y := 0; y < h; y++ { img.SetColorIndex(x, y, ci) } } } func hsb2rgb(hue, sat, bri flo...
#include<windows.h> #include<stdlib.h> #include<stdio.h> #include<time.h> #include<math.h> #define pi M_PI int main() { CONSOLE_SCREEN_BUFFER_INFO info; int cols, rows; time_t t; int i,j; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); cols = info.srWindow.Right - info.srWindow.Lef...
Keep all operations the same but rewrite the snippet in C.
package main import ( "bytes" "fmt" "log" ) func wordle(answer, guess string) []int { n := len(guess) if n != len(answer) { log.Fatal("The words must be of the same length.") } answerBytes := []byte(answer) result := make([]int, n) for i := 0; i < n; i++ { if guess...
#include <stdio.h> #include <stdlib.h> #include <string.h> void wordle(const char *answer, const char *guess, int *result) { int i, ix, n = strlen(guess); char *ptr; if (n != strlen(answer)) { printf("The words must be of the same length.\n"); exit(1); } char answer2[n+1]; strcp...
Rewrite the snippet below in C so it works the same as the original Go code.
package main import ( "container/heap" "image" "image/color" "image/png" "log" "math" "os" "sort" ) func main() { f, err := os.Open("Quantum_frog.png") if err != nil { log.Fatal(err) } img, err := png.Decode(f) if ec := f.Close(); err != nil { log.Fa...
typedef struct oct_node_t oct_node_t, *oct_node; struct oct_node_t{ uint64_t r, g, b; int count, heap_idx; oct_node kids[8], parent; unsigned char n_kids, kid_idx, flags, depth; }; inline int cmp_node(oct_node a, oct_node b) { if (a->n_kids < b->n_kids) return -1; if (a->n_kids > b->n_kids) return 1; int ac...
Rewrite this program in C while keeping its functionality equivalent to the Go version.
package main import ( "fmt" "go/ast" "go/parser" "go/token" "io/ioutil" "os" "sort" ) func main() { if len(os.Args) != 2 { fmt.Println("usage ff <go source filename>") return } src, err := ioutil.ReadFile(os.Args[1]) if err != nil { fmt.Println(err) ...
#define _POSIX_SOURCE #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <stddef.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> struct functionInfo { char* name; int timesCalled; char marked; }; void addToList(...
Can you help me rewrite this code in C instead of Go, keeping it the same logically?
package main import ( "fmt" "go/ast" "go/parser" "go/token" "io/ioutil" "os" "sort" ) func main() { if len(os.Args) != 2 { fmt.Println("usage ff <go source filename>") return } src, err := ioutil.ReadFile(os.Args[1]) if err != nil { fmt.Println(err) ...
#define _POSIX_SOURCE #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <stddef.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> struct functionInfo { char* name; int timesCalled; char marked; }; void addToList(...
Produce a functionally identical C code for the snippet given in Go.
var i int var u rune for i, u = range "voilà" { fmt.Println(i, u) }
#include <stdio.h> #include <stdlib.h> #include <locale.h> wchar_t poker[] = L"♥♦♣♠"; wchar_t four_two[] = L"\x56db\x5341\x4e8c"; int main() { if (!setlocale(LC_CTYPE, "")) { fprintf(stderr, "Locale failure, check your env vars\n"); return 1; } #ifdef __STDC_ISO_10646__ printf(...
Write the same algorithm in C as shown in this Go implementation.
var i int var u rune for i, u = range "voilà" { fmt.Println(i, u) }
#include <stdio.h> #include <stdlib.h> #include <locale.h> wchar_t poker[] = L"♥♦♣♠"; wchar_t four_two[] = L"\x56db\x5341\x4e8c"; int main() { if (!setlocale(LC_CTYPE, "")) { fprintf(stderr, "Locale failure, check your env vars\n"); return 1; } #ifdef __STDC_ISO_10646__ printf(...
Maintain the same structure and functionality when rewriting this code in C.
package main import ( "log" "os/exec" "raster" ) func main() { c := exec.Command("convert", "Unfilledcirc.png", "-depth", "1", "ppm:-") pipe, err := c.StdoutPipe() if err != nil { log.Fatal(err) } if err = c.Start(); err != nil { log.Fatal(err) } b, err := ...
image read_image(const char *name);
Write the same algorithm in C as shown in this Go implementation.
package main import ( "fmt" "html/template" "log" "os" "os/exec" "strings" "time" ) type row struct { Address, Street, House, Color string } func isDigit(b byte) bool { return '0' <= b && b <= '9' } func separateHouseNumber(address string) (street string, house string) { leng...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "wren.h" void C_fileAllocate(WrenVM* vm) { FILE** pfp = (FILE**)wrenSetSlotNewForeign(vm, 0, 0, sizeof(FILE*)); const char *filename = wrenGetSlotString(vm, 1); const char *mode = wrenGetSlotString(vm, 2); *pfp ...
Please provide an equivalent version of this Go code in C.
package main import "fmt" type rs232p9 uint16 const ( CD9 rs232p9 = 1 << iota RD9 TD9 DTR9 SG9 DSR9 RTS9 CTS9 RI9 ) func main() { ...
struct RS232_data { unsigned carrier_detect : 1; unsigned received_data : 1; unsigned transmitted_data : 1; unsigned data_terminal_ready : 1; unsigned signal_ground : 1; unsigned data_set_ready : 1; unsigned request_to_send : 1; unsigned clear_to_send :...
Port the provided Go code into C while preserving the original functionality.
package main import ( "fmt" "rcu" ) func main() { primes := rcu.Primes(999) sum := 0 fmt.Println(" i p[i] Σp[i]") fmt.Println("----------------") for i := 0; i < len(primes); i += 2 { sum += primes[i] if rcu.IsPrime(sum) { fmt.Printf("%3d %3d %6s\n", i+1, p...
#include<stdio.h> #include<stdlib.h> int isprime( int p ) { int i; if(p==2) return 1; if(!(p%2)) return 0; for(i=3; i*i<=p; i+=2) { if(!(p%i)) return 0; } return 1; } int main( void ) { int s=0, p, i=1; for(p=2;p<=999;p++) { if(isprime(p)) { if(i%2) { ...
Write a version of this Go function in C with identical behavior.
package main import ( "fmt" "rcu" ) func main() { primes := rcu.Primes(999) sum := 0 fmt.Println(" i p[i] Σp[i]") fmt.Println("----------------") for i := 0; i < len(primes); i += 2 { sum += primes[i] if rcu.IsPrime(sum) { fmt.Printf("%3d %3d %6s\n", i+1, p...
#include<stdio.h> #include<stdlib.h> int isprime( int p ) { int i; if(p==2) return 1; if(!(p%2)) return 0; for(i=3; i*i<=p; i+=2) { if(!(p%i)) return 0; } return 1; } int main( void ) { int s=0, p, i=1; for(p=2;p<=999;p++) { if(isprime(p)) { if(i%2) { ...
Please provide an equivalent version of this Go code in C.
package main import ( "fmt" "rcu" ) func main() { primes := rcu.Primes(999) sum := 0 fmt.Println(" i p[i] Σp[i]") fmt.Println("----------------") for i := 0; i < len(primes); i += 2 { sum += primes[i] if rcu.IsPrime(sum) { fmt.Printf("%3d %3d %6s\n", i+1, p...
#include<stdio.h> #include<stdlib.h> int isprime( int p ) { int i; if(p==2) return 1; if(!(p%2)) return 0; for(i=3; i*i<=p; i+=2) { if(!(p%i)) return 0; } return 1; } int main( void ) { int s=0, p, i=1; for(p=2;p<=999;p++) { if(isprime(p)) { if(i%2) { ...
Translate the given Go code snippet into C without altering its behavior.
package main import ( "fmt" "math" "rcu" ) func main() { limit := int(math.Log(1e7) * 1e7 * 1.2) primes := rcu.Primes(limit) fmt.Println("The first 20 pairs of natural numbers whose sum is prime are:") for i := 1; i <= 20; i++ { p := primes[i] hp := p / 2 fmt.Print...
#include <stdio.h> #include <stdlib.h> #include <math.h> #define TRUE 1 #define FALSE 0 typedef int bool; void primeSieve(int *c, int limit, bool processEven, bool primesOnly) { int i, ix, p, p2; limit++; c[0] = TRUE; c[1] = TRUE; if (processEven) { for (i = 4; i < limit; i +=2) c[i] = TR...
Write the same code in C as shown below in Go.
package main import ( "fmt" "math" ) func isqrt(x uint64) uint64 { x0 := x >> 1 x1 := (x0 + x/x0) >> 1 for x1 < x0 { x0 = x1 x1 = (x0 + x/x0) >> 1 } return x0 } func gcd(x, y uint64) uint64 { for y != 0 { x, y = y, x%y } return x } var multiplier = []u...
#include <math.h> #include <stdio.h> #define nelems(x) (sizeof(x) / sizeof((x)[0])) const unsigned long multiplier[] = {1, 3, 5, 7, 11, 3*5, 3*7, 3*11, 5*7, 5*11, 7*11, 3*5*7, 3*5*11, 3*7*11, 5*7*11, 3*5*7*11}; unsigned long long gcd(unsigned long long a, unsigned long long b) { while (b != 0) { a %=...
Change the programming language of this snippet from Go to C without modifying what it does.
package main import ( "fmt" "math" ) func isqrt(x uint64) uint64 { x0 := x >> 1 x1 := (x0 + x/x0) >> 1 for x1 < x0 { x0 = x1 x1 = (x0 + x/x0) >> 1 } return x0 } func gcd(x, y uint64) uint64 { for y != 0 { x, y = y, x%y } return x } var multiplier = []u...
#include <math.h> #include <stdio.h> #define nelems(x) (sizeof(x) / sizeof((x)[0])) const unsigned long multiplier[] = {1, 3, 5, 7, 11, 3*5, 3*7, 3*11, 5*7, 5*11, 7*11, 3*5*7, 3*5*11, 3*7*11, 5*7*11, 3*5*7*11}; unsigned long long gcd(unsigned long long a, unsigned long long b) { while (b != 0) { a %=...
Rewrite this program in C while keeping its functionality equivalent to the Go version.
package main import ( "github.com/fogleman/gg" "log" "os/exec" "runtime" ) var palette = [2]string{ "FFFFFF", "000000", } func pinstripe(dc *gg.Context) { w := dc.Width() h := dc.Height() / 7 for b := 1; b <= 11; b++ { for x, ci := 0, 0; x < w; x, ci = x+b, ci+1 { ...
#include <stdlib.h> #include <string.h> #include "dome.h" static DOME_API_v0* core; static WREN_API_v0* wren; static const char* source = "" "class Printer {\n" "foreign static printFile(name) \n" "} \n"; void C_printFile(WrenVM* vm) { const char *arg = wren->getSlotString(vm, 1); char command[strlen(a...
Preserve the algorithm and functionality while converting the code from Go to C.
package main import ( "github.com/fogleman/gg" "log" "os/exec" "runtime" ) var palette = [2]string{ "FFFFFF", "000000", } func pinstripe(dc *gg.Context) { w := dc.Width() h := dc.Height() / 7 for b := 1; b <= 11; b++ { for x, ci := 0, 0; x < w; x, ci = x+b, ci+1 { ...
#include <stdlib.h> #include <string.h> #include "dome.h" static DOME_API_v0* core; static WREN_API_v0* wren; static const char* source = "" "class Printer {\n" "foreign static printFile(name) \n" "} \n"; void C_printFile(WrenVM* vm) { const char *arg = wren->getSlotString(vm, 1); char command[strlen(a...
Maintain the same structure and functionality when rewriting this code in C.
package main import ( "fmt" "sort" ) type ( Point [3]float64 Face []int Edge struct { pn1 int pn2 int fn1 int fn2 int cp Point } PointEx struct { p Point n int } ) func sumPoint(p1, p2 Point) Point { sp := Po...
vertex face_point(face f) { int i; vertex v; if (!f->avg) { f->avg = vertex_new(); foreach(i, v, f->v) if (!i) f->avg->pos = v->pos; else vadd(f->avg->pos, v->pos); vdiv(f->avg->pos, len(f->v)); } return f->avg; } #define hole_edge(e) (len(e->f)==1) vertex edge_point(edge e) { int i; face f; ...
Write a version of this Go function in C with identical behavior.
package main import ( "fmt" "sort" ) type ( Point [3]float64 Face []int Edge struct { pn1 int pn2 int fn1 int fn2 int cp Point } PointEx struct { p Point n int } ) func sumPoint(p1, p2 Point) Point { sp := Po...
vertex face_point(face f) { int i; vertex v; if (!f->avg) { f->avg = vertex_new(); foreach(i, v, f->v) if (!i) f->avg->pos = v->pos; else vadd(f->avg->pos, v->pos); vdiv(f->avg->pos, len(f->v)); } return f->avg; } #define hole_edge(e) (len(e->f)==1) vertex edge_point(edge e) { int i; face f; ...
Generate a C translation of this Go snippet without changing its computational steps.
package main import ( "fmt" "io/ioutil" "net/http" "regexp" "sort" "strings" ) type authorNumber struct { author string number int } func main() { ex1 := `<li><a href="/wiki/(.*?)"` ex2 := `a href="/(wiki/User:|mw/index\.php\?title=User:|wiki/Special:Contributions/)([^"&]+)` ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <curl/curl.h> #include "wren.h" struct MemoryStruct { char *memory; size_t size; }; static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *m...
Change the programming language of this snippet from Go to C without modifying what it does.
package main import ( "fmt" "io/ioutil" "net/http" "regexp" "sort" "strings" ) type authorNumber struct { author string number int } func main() { ex1 := `<li><a href="/wiki/(.*?)"` ex2 := `a href="/(wiki/User:|mw/index\.php\?title=User:|wiki/Special:Contributions/)([^"&]+)` ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <curl/curl.h> #include "wren.h" struct MemoryStruct { char *memory; size_t size; }; static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *m...