Search the Community
Showing results for tags 'c'.
-
Today I have another "why is this faster than this?" because I have nothing else to do in my life. Like seriously, you all might get tired replying my posts because all I say does not even really matter, but once I get this question in my head, it will bother me so I can't stop. You know how "ptr" is the same as "*(ptr + i)"? Upon testing, looks like it is not. And the difference is actually something I can talk about. clock_gettime(CLOCK_MONOTONIC, &start); for (int i = 0; i < iteration; i++){ for (int i = 0; str[i]; i++); } clock_gettime(CLOCK_MONOTONIC, &end); printf("%ld\n", end.tv_nsec - start.tv_nsec); clock_gettime(CLOCK_MONOTONIC, &start); for (int i = 0; i < iteration; i++){ for (int i = 0; *(str + i); i++); } clock_gettime(CLOCK_MONOTONIC, &end); printf("%ld\n", end.tv_nsec - start.tv_nsec); This is only a snippet of my main because the string is so BIG it almost crashes VSCode. Anyways, the second loop is quite a bit faster than the first. First loop uses array indexing whereas the second loop uses pointer arithmetic. Ah yes, the assembly code. Only if I could read it! main: pushq %rbp .seh_pushreg %rbp movq %rsp, %rbp .seh_setframe %rbp, 0 subq $96, %rsp .seh_stackalloc 96 .seh_endprologue call __main leaq .LC0(%rip), %rax movq %rax, -24(%rbp) leaq -48(%rbp), %rax movq %rax, %rdx movl $1, %ecx call clock_gettime movl $0, -4(%rbp) jmp .L4 .L7: movl $0, -8(%rbp) jmp .L5 .L6: addl $1, -8(%rbp) .L5: movl -8(%rbp), %eax cltq movq -24(%rbp), %rdx addq %rdx, %rax movzbl (%rax), %eax testb %al, %al jne .L6 addl $1, -4(%rbp) .L4: cmpl $0, -4(%rbp) jle .L7 leaq -64(%rbp), %rax movq %rax, %rdx movl $1, %ecx call clock_gettime movl -56(%rbp), %eax movl -40(%rbp), %edx subl %edx, %eax movl %eax, %edx leaq .LC1(%rip), %rax movq %rax, %rcx call printf leaq -48(%rbp), %rax movq %rax, %rdx movl $1, %ecx call clock_gettime movl $0, -12(%rbp) jmp .L8 .L11: movl $0, -16(%rbp) jmp .L9 .L10: addl $1, -16(%rbp) .L9: movl -16(%rbp), %eax cltq movq -24(%rbp), %rdx addq %rdx, %rax movzbl (%rax), %eax testb %al, %al jne .L10 addl $1, -12(%rbp) .L8: cmpl $0, -12(%rbp) jle .L11 leaq -64(%rbp), %rax movq %rax, %rdx movl $1, %ecx call clock_gettime movl -56(%rbp), %eax movl -40(%rbp), %edx subl %edx, %eax movl %eax, %edx leaq .LC1(%rip), %rax movq %rax, %rcx call printf movl $0, %eax addq $96, %rsp popq %rbp ret This is the only part which seems to be relevant.
-
How is pointer incrementation faster than addition in C?
Gat Pelsinger posted a topic in Programming
#include <stdio.h> #include <time.h> const char* str = "Hello"; int func1() { register int i = 0; for (; str[i]; i++); return i; } int func2() { register char* i = str; for (; *i; i++); return (int)(i - str); } int main() { struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); int a = func1(); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %ld\n", a, end.tv_nsec - start.tv_nsec); clock_gettime(CLOCK_MONOTONIC, &start); int b = func2(); clock_gettime(CLOCK_MONOTONIC, &end); printf("%d %ld\n", b, end.tv_nsec - start.tv_nsec); return 0; } Both func1 and func2 return the length of the string. func1 uses pointer addition based approach where it adds a value to the address of 'str' and virtually increments it, whereas func2 uses a pointer incrementation approach, where it makes a new pointer instead of a variable, sets it to the address of 'str', and increments it. Upon running the code, it seems that func2 is way faster than func1. Why is that? Isn't the time complexity of addition O(1)? And upon that, in func2 we are physically incrementing a pointer, which is a memory bounded task (well technically, because our code is so small it might wholly reside in the cache and never hit system memory) instead of a compute bounded. Compute bounding is better than memory bounding. -
So I made a function which benchmarks other functions. Because of my countless failures of achieving generics, I reluctantly had to make different bench functions for different data types. Right now, only the bool version is complete but I will add more functions. I have one question. I am using the same variable names in my union. In my function when I try to access "res", VScode Intellisense shows be something like "bool::res", which probably means it identified that it should use the "res" variable of bool type, because I am taking a bool return type out of the function pointer. But after I return the struct, in my main, if I try to access "res", then which "res" will it choose? I know I've done something wrong. #include <time.h> #include <stdbool.h> #include <stdarg.h> #define RUNS 5 #define AVG_RUNS 5 union result{ //to store the result of the function of any data type because GENERICS SUCKS. bool res; char res; short signed int res; signed int res; long signed int res; long long signed int res; short unsigned int res; unsigned int res; long unsigned int res; long long unsigned int res; char* res; }; struct bench{ // We do 5 runs, calculate average and repeat 5 times. Then we calculate the total average of all the 5 averages. We also maintain the highest and lowest. // Could have used arrays but who cares. long unsigned int run1; long unsigned int run2; long unsigned int run3; long unsigned int run4; long unsigned int run5; long unsigned int average1; long unsigned int average2; long unsigned int average3; long unsigned int average4; long unsigned int average5; long unsigned int total_average; long unsigned int highest; long unsigned int lowest; }; struct bench_result{ //Our bench function(s) will return this. long unsigned int elapsed; union result result; }; inline struct bench_result bench_bool(bool (*funcPtr)(va_list), ...) //Only works on boolean functions. Will add more functions which use other data types. All this because GENERICS SUCKS! { struct timespec start, end; //to measure time va_list args; //to pass the args to the function. va_start(args, funcPtr); struct bench bench; union result result; long unsigned int* runP = &bench.run1; //to iterate over the variables. long unsigned int* avgP = &bench.average1; long unsigned int avg_accumulator = 0ULL; //accumulator to add the values for calculating average for (unsigned char i = 0; i < AVG_RUNS; i++) { for (unsigned char j = 0; j < RUNS; j++) { clock_gettime(CLOCK_MONOTONIC, &start); result.res = funcPtr(args); //notice, we are storing the the result in our union clock_gettime(CLOCK_MONOTONIC, &end); *runP = end.tv_nsec - start.tv_nsec; //storing the elapsed time in the current run avg_accumulator += *runP; //adding the time to the accumulator runP++; //update pointer } *avgP = avg_accumulator / RUNS; //calculating average avg_accumulator = 0ULL; //resetting accumulator avgP++; //update pointer //long ass convuluted ternaries for calculating highest and lowest long unsigned int highest_current = (bench.run1 > bench.run2 ? (bench.run1 > bench.run3 ? (bench.run1 > bench.run4 ? (bench.run1 > bench.run5 ? bench.run1 : bench.run5) : (bench.run4 > bench.run5 ? bench.run4 : bench.run5)) : (bench.run3 > bench.run4 ? (bench.run3 > bench.run5 ? bench.run3 : bench.run5) : (bench.run4 > bench.run5 ? bench.run4 : bench.run5))) : (bench.run2 > bench.run3 ? (bench.run2 > bench.run4 ? (bench.run2 > bench.run5 ? bench.run2 : bench.run5) : (bench.run4 > bench.run5 ? bench.run4 : bench.run5)) : (bench.run3 > bench.run4 ? (bench.run3 > bench.run5 ? bench.run3 : bench.run5) : (bench.run4 > bench.run5 ? bench.run4 : bench.run5)))); bench.highest = highest_current > bench.highest ? highest_current : bench.highest; long unsigned int lowest_current = (bench.run1 < bench.run2 ? (bench.run1 < bench.run3 ? (bench.run1 < bench.run4 ? (bench.run1 < bench.run5 ? bench.run1 : bench.run5) : (bench.run4 < bench.run5 ? bench.run4 : bench.run5)) : (bench.run3 < bench.run4 ? (bench.run3 < bench.run5 ? bench.run3 : bench.run5) : (bench.run4 < bench.run5 ? bench.run4 : bench.run5))) : (bench.run2 < bench.run3 ? (bench.run2 < bench.run4 ? (bench.run2 < bench.run5 ? bench.run2 : bench.run5) : (bench.run4 < bench.run5 ? bench.run4 : bench.run5)) : (bench.run3 < bench.run4 ? (bench.run3 < bench.run5 ? bench.run3 : bench.run5) : (bench.run4 < bench.run5 ? bench.run4 : bench.run5)))); bench.lowest = lowest_current < bench.lowest ? lowest_current : bench.lowest; runP = &bench.run1; } bench.total_average = (bench.average1 + bench.average2 + bench.average3 + bench.average4 + bench.average5) / AVG_RUNS; //calculate the final avetage struct bench_result res; res.elapsed = bench.total_average; res.result = result; //passing the union itself va_end(args); return res; } Also, is it hard for you guys to read code on this forum? If so, I might post the code on some other website. It's shocking I don't have a GitHub account yet.
-
#include <stdio.h> #include <stdlib.h> int main(){ unsigned long long *a = NULL; a = malloc(1024 * 1024 * 1024); if (a == NULL){ printf("a is NULL"); } else {printf("%p", a);} getchar(); return 0; } I want to allocate a gigabyte of memory in one go. But it is not working. If I print the value of 'a', I get random numbers and letters, likely being the memory address, and also because I do not understand pointers fully (yes, this is a side question), if I print the value of "*a", I get all zeroes. So, this means the value being pointed by 'a' is zero? What is this exactly supposed to mean? Isn't 'a' taking the memory address of the new allocated memory? Anyways, why this code not workyyyyy.
-
C - "Access violation writing location" when inputing string
Matttaj69 posted a topic in Programming
Hi, I am working on a simple code in C, have got the logic almost sorted. However, in order for my program to work, I need a user to input a string. I have tried <scanf_s("%s", potr);> (shown in picture), but while debugging, it has ended on that line with "Access violation writing location" error. I have tried putting the string directly as a parameter in the function call, which worked perfectly fine. Any ideas what could be wrong? Notice: long story short, I must use Microsoft Visual Studio and the "safe" version of scanf. Screenshot of the part of my code: Thanks in advance -
Hi all, I'm teaching myself C programming following a book and the next tutorials use GTK. I downloaded it using a MSYS2 Shell but when I compile the code I just get the error in the pic. Also attached a pic of the MSYS2 shell following the download. Any help much appreciated!
- 18 replies
-
- c
- c prgramming
-
(and 1 more)
Tagged with:
-
I want to use Atom as my IDE. I know its not, but I have heard that you can set it up with the gcc compiler to act like an IDE, but since I am new to POP OS and linux in general I don't know how to do so. I used to use VS Community edition on windows but then I moved to Pop OS and am on the lookout for an IDE or an Editor + Compiler setup.
-
im learing c with cs50 but im confused what does int main (void) mean
-
Hi everyone, I am loking for some software solution to auto control screen brightness through the webcam (I do not have a light sensor in my monitor and would prefer not to buy an external one). I looked around and found this Clight on github GitHub - FedeDP/Clight: A C daemon that turns your webcam into a light sensor. It will adjust screen backlight based on ambient brightness. It seems one of the only options, but I am not a programmer and not really confident with code, and I am not able to understand how to use the program and if it is compatible. I am currently on windows 10, and I see that in the code there is written archlinux. This makes me think it is a linux only app, but hope never dies, and maybe there is a workaround with the windows subsystem for linux? Also an alternative using something like python would be a nice project to work on for me. (I know python basics but usually work on R for statistical reasons, I know R is more similar to C probably). Let me know if you have any suggestion.
- 2 replies
-
- brightness
- python
-
(and 4 more)
Tagged with:
-
I need an USB-C hub which connects to my USB-C 3.2 Gen 2 with DP 1.4 port. The Displayport is the most important thing from everything else but I would also need multiple USB-A ports for peripherals and other stuff. The DP should be capable of 1080p at 144 Hz (or 120 Hz im still deciding(or 1440p 120 Hz)).
-
So I have a code which calculates the class average, boys highest mark, girls highest mark, lowest mark etc. When I enter the number of boys value below 10, I can enter any number of girls in the class and calculate many marks as I need (As seen in image) Now the problem is when I enter number of boys value as 10 or above I can't enter number of girls value greater than 10... It simply crashes and shoes a message as shown in the image. And I have another problem in my code where I can successfully display the index who got the highest mark in both boys and girls but I can't display the index who got the lowest mark in both boys and girls... If I try to to it shows "The lowest mark in [boys/girls]* is [boy/girl]* 0 with 0 marks" *Statements are separate Here is my code (THIS IS C PROGRAM) #include <stdio.h> #include <stdlib.h> int bhigh(int b[], int c) //*Finding highest mark in boys*// { int i, index = 0; for (i = 1; i <= c; i++) if (b[i] > b[index]) index = i; return index; } int blow(int b[], int c) //*Finding lowest mark in boys*// { int i; int min = b[1]; for (i = 1; i <= c; i++) if (b[i] < min) min = b[i]; return min; } int ghigh(int g[], int d) //*Finding highest mark in girls*// { int i, index = 0; for (i = 1; i <= d; i++) if (g[i] > g[index]) index = i; return index; } int glow(int g[], int d) //*Finding lowest mark in girls*// { int i; int min = g[1]; for (i = 1; i <= d; i++) if (g[i] < min) min = g[i]; return min; } int main() { int i,c,d; int *b,*g; int bhighlocation, bmaximum, blowlocation, bminimum; int ghighlocation, gmaximum, glowlocation, gminimum; float sum1=0,sum2=0,avg1,avg2,clsavg; printf("C PROGRAM FOR A CLASS MARK LIST FOR BOYS AND GIRLS\n\n"); //*Getting no. of boys*// printf("Enter the number of boys: "); scanf("%d",&c); b=(int*)malloc(c*sizeof(int)); //*Getting boys marks*// printf("\nEnter the marks of boys :\n"); for(i=1;i<=c;i++) { printf(" -Enter marks of boys %d: ",i); scanf("%d",&b[+i]); } //*Getting no. of girls*// printf("\nEnter the number of girls: "); scanf("%d",&d); g =(int*)malloc(d*sizeof(int)); //*Getting girls marks*// printf("\nEnter the marks of girls :\n"); for(i=1;i<=d;i++) { printf(" -Enter mark of girl %d: ",i); scanf("%d",&g[+i]); } //*Computing average marks of boys*// for(i=1;i<=c;i++) { sum1 = sum1+b[i]; } avg1=sum1/c; printf("\nThe average of boys marks is : %.2f\n",avg1); //*Computing average marks of girls*// for(i=1;i<=d;i++) { sum2 = sum2+g[i]; } avg2=sum2/d; printf("The average of girls marks is : %.2f\n",avg2); //*Computing overall class average*// clsavg=(avg1+avg2)/2; printf("The overall class average is : %.2f\n",clsavg); //*Printing highest mark between boys*// bhighlocation = bhigh(b, c); bmaximum = b[bhighlocation]; printf("\nHighest mark in boys is boy %d with %d marks.\n", bhighlocation, bmaximum); //*Printing lowest mark between boys*// printf("Lowest mark in boys is %d\n", blow(b, c)); //*Printing highest mark between girls*// ghighlocation = ghigh(g, d); gmaximum = g[ghighlocation]; printf("\nHighest mark in girls is girl %d with %d marks.\n", ghighlocation, gmaximum); //*Printing lowest mark between girls*// printf("Lowest mark in girls is %d\n", glow(g, d)); return 0; } Sorry if my code's too large.....
-
Hi guys! I need a help ASAP! This is my C program for arranging an array in ascending and descending order using BUBBLE SORT method.... I need to make use of functions my program... But I'm finding it hard to convert it.... So if anybody is an expert in this please reply me with converted code.... Try my code first to get a better understanding of the output... #include <stdio.h> int main() { int arr[30]; int i, j, a, n; printf("ELEMENT BUBBLE SORTER - ASCENDING AND DESCENDING\n"); printf("Enter the number of elements to be sorted = "); scanf("%d", &n); printf("\nEnter the number values one by one\n"); for (i = 0; i < n; i++) scanf("%d", &arr[i]); for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (arr[i] > arr[j]) { a = arr[i]; arr[i] = arr[j]; arr[j] = a; } } } printf("\nThe numbers arranged in ascending order are given below\n"); for (i = 0; i < n; i++) { printf("%d\n", arr[i]); } for (i = 0; i < n; i++) { for (j = i + 1; j < n; ++j) { if (arr[i] < arr[j]) { a = arr[i]; arr[i] = arr[j]; arr[j] = a; } } } printf("\nThe numbers arranged in descending order are given below\n"); for (i = 0; i < n; i++) { printf("%d\n", arr[i]); } return 0; }
- 3 replies
-
- c program
- code expert help needed
-
(and 4 more)
Tagged with:
-
This is my C program for reading and displaying flight ticket details... Pls compile and see the errors then help me fix it.... I am blankly saying this bcoz IDK how to explain my issue.... I promise this will be easier to fix than my last code.......... There are some pointer errors that's what I need to fix... Thanks BTW #include <stdio.h> typedef struct { int ptickno; char pname[100]; char flightname[100]; char fdate[100]; char fltime[100]; char class[100]; char gate[100]; char seat[100]; char from[100]; char to[100]; }passenger; void input_output(passenger p1[100]) { int i=0; int n; int *ticket; ticket=&p1->ptickno; char *passname, *airplanename, *airdate, *airtime, *flclass, *airgate, *airseat, *flyfrom, *flyto; passname=p1->pname; airplanename=p1->flightname; airdate=p1->fdate; airtime=p1->fltime; flclass=p1->class; airgate=p1->gate; airseat=p1->seat; flyfrom=p1->from; flyto=p1->to; printf("ENTER THE NUMBER OF TICKETS YOU WANT TO ENTER : "); scanf("%d",&n); for(i=0;i<n;i++) { printf("\n********************************************"); printf("\nENTRY FOR PASSENGER %d :", i+1); printf("\n\nEnter ticket number : "); scanf("%d",&p1[i](*ticket)); printf("Enter name of passenger : "); scanf("%s",p1[i](passname)); printf("Enter name of flight : "); scanf("%s",p1[i](airplanename)); printf("Enter date of flight : "); scanf("%s",p1[i](airdate)); printf("Enter time of flight : "); scanf("%s",p1[i](airtime)); printf("Enter class : "); scanf("%s",p1[i](flclass)); printf("Enter gate : "); scanf("%s",p1[i](airgate)); printf("Enter seat : "); scanf("%s",p1[i](airseat)); printf("Enter from : "); scanf("%s",p1[i](flyfrom)); printf("Enter to : "); scanf("%s",p1[i](flyto)); printf("********************************************\n"); } for(i=0;i<n;i++) { printf("\n********************************************"); printf("\nTICKET DETAILS OF PASSENGER %d",i+1); printf("\n\nTICKET NUMBER : %d",p1[i](*ticket)); printf("\nNAME OF PASSENGER : %s",p1[i](passname)); printf("\nNAME OF FLIGHT : %s",p1[i](airplanename)); printf("\nDATE OF FLIGHT : %s",p1[i](airdate)); printf("\nTIME OF FLIGHT : %s",p1[i](airtime)); printf("\nCLASS : %s",p1[i](flclass)); printf("\nGATE : %s",p1[i](airgate)); printf("\nSEAT : %s",p1[i](airseat)); printf("\nFROM : %s",p1[i](flyfrom)); printf("\nTO : %s",p1[i](flyto)); printf("\n********************************************"); } } int main() { passenger p[100],*pptr; pptr=&p[0]; input_output(pptr); return 0; }
- 14 replies
-
Hey guys, I am converting a temperature from a piece of equipment and the given unit conversion is very strange. I have sliced this problem up a couple of different ways but I am not getting anywhere. The given information is (see attached) data type: unsigned 16 bit word data range: -110.0degC to 150.0degC input range: 0xFBB4 to 0x5DC There is one example in the manual, 0x00EE == 23.8degC. Any idea how to convert this to a C++ function to convert between the two? Thanks.
-
Hello everyone, I was searching for a good RAM stick and I came along some weird naming convention of Samsung. They have some sticks with the same specs but different names. The M471A2K43CB1-CTD, M471A2K43DB1-CTD and M471A2K43EB1-CTD. Appearantely the only difference is the 10th character which is a c, d or e. Does anyone have an idea, what they mean? Thank you.
-
Making a pc build for my friend. is this good or no?
d8nni posted a topic in New Builds and Planning
Budget (including currency): $1300 Country: united states Games, programs or workloads that it will be used for: Other details (existing parts lists, whether any peripherals are needed, what you're upgrading from, when you're going to buy, what resolution and refresh rate you want to play at, etc): ALLL NEW https://pcpartpicker.com/user/DannyV./saved/tGCqHx -
Hi, I'm attempting to combine row/column 2-D arrays outputted from each process into a single complete 2-D array on all processes. Essentially, I have a large NxN 2-D array (4000x4000 +) that requires the same operation to be carried out on all elements. My intention is to break this down into either sections of rows or columns that each process will complete. I need each process to have the entirety of the array once all sections have been completed. I have looked at multiple examples of using these MPI instructions but could not find one that combined rows/columns from N processes. Could someone please inform me as to how I can implement this? Below is a boilerplate example of what I'm trying to achieve. Each process creates a master matrix and then calculates the set of rows it's responsible for. It then creates a 2-D array of that size and copies the data from the master. It then carries out its operation on each element of the 2-D array. I then need to use Allgatherv to collect each process's 2-D array and combine them to overwrite the master matrix. Please note that it is not important whether I use rows or columns from my point of view, I believed sticking to one and not trying to create multiple submatrices would allow me to easily increase the number of processes running without added complexity. #include <stdio.h> #include <stdlib.h> #include <mpi.h> double **alloc_2d_array(int m, int n) { double **x; int i; x = (double **)malloc(m*sizeof(double *)); x[0] = (double *)calloc(m*n,sizeof(double)); for ( i = 1; i < m; i++ ) x[i] = &x[0][i*n]; return x; } void main(int argc, char *argv[]) { int n = 8; int rank, size; int root_rank = 0; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); // Report active to console printf("Rank: %d, reporting!\n", rank); // Make master matrix double ** master_matrix = alloc_2d_array(n, n); // Set starting values in master matrix for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { master_matrix[i][j] = i*n+j; } } // Calculate each ranks section of matrix int interval = n/size; int section_end = interval*(rank+1); int section_start = section_end - interval; if (rank == size-1) { section_end += n % size; } int section_length = section_end-section_start; printf("Start: %d, End: %d\n", section_start, section_end); // Make local rows double ** local_sect = alloc_2d_array(section_length, n); // Set local rows to master_matrix rows for (int i=0; i<section_length; i++) { local_sect[i] = master_matrix[i]; } // Carry out operation (in this example, adding 7) for (int i=0; i<section_length; i++) { for (int j=0; j<n; j++) { local_sect[i][j] = local_sect[i][j]+7; } } // Use Allgatherv to overwrite master matrix to new complete matrix // MPI_Allgatherv(my_values, my_values_count, MPI_INT, buffer, counts, displacements, MPI_INT, MPI_COMM_WORLD); // Print new master matrix out on all processes printf("NEW MASTER MATRIX\n"); for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { printf("%f ", master_matrix[i][j]); } printf("\n"); } MPI_Finalize(); }
- 1 reply
-
- c
- multidimentional array
-
(and 2 more)
Tagged with:
-
I figured I'd try to start writing again (my memory's such garbage that I let what little I did learn and retain lie for quite a while and die) and I'm getting an odd output. < #include <stdio.h> int main() { int age; printf("Enter your age : "); scanf_s("%d",&age); printf("your age is %d"); return 0; }> I'm lost as to what it could be.
-
Hello, so I'm looking into creating a "AI" smart home from scratch for a DIY project. so Linus did a video on the Anker speackers where he paired 100 of them together, now I want to have my Ai speak to me also, I can toi that with System.Speech API on windows, I am using a windows machine to power it. I'm wondering if I can have my program find every speaker paired (around 15 maybe) and what ever room I'm speaking from the speaker in that room with give the ouput instead of all 15 speakers in the house. I also would like to know about multiple mics? This program does work because I've had it in my room before I moved out of my parents.
-
int main(int argc, char **argv) { FILE *f = fopen("/dev/tty", "r+"); SCREEN *screen = newterm(NULL, f, f); set_term(screen); curs_set(0); // some program logic and output here getch(); endwin(); delscreen(screen); return EXIT_SUCCESS; } After exiting, the Terminal settings are not properly restored and I can't figure out how to solve this. The common issue, according to the internet, seems to be not calling endwin() as last action, but this doesn't work for me. I also tried without calling delscreen. And I tried applying the same to the previous screen (return value of set_term). Btw, the reason why I use newterm instead of initscr is because I need clean stdin/stdout for data processing.
-
Hi im learning C & C++ as my first language! I know it would be easier to start out with something like java or HTML but as a freshmen in high-school thats what we decided to learn or i anyways its a self taught coarse for those whom might be interested and i being the geek that i am decided to jump on it not knowing what I'm getting into so in retrospect i need help on where to learn this language from and preferably it being simple i would also like to learn any tips and easy tricks i would might want to know to help me face this "intimidating" programming language.
-
Title. Mine would be : "You left out the expensive laptop at your roof" & " Invest on forum based premium content instead of vessel early " "Dont do that fractal spicy chilly challenge" Plus others, Post Your thoughts/replies down below!
-
Hey guys, so a friend and I had a really interesting Talk. During that talk we talked about Access Points that can reach a distance of 2km. You can normally connect to them and we understand that receiving data ist easy, but how can the client, in this case the phone, send data to the access point. In our perspective the phones antenna shouldn't be strong enough. So how can the phone "Upload" Data? Hope you guys can help me. Couldn't find anything during my Research. Thanks for some enlightment
- 6 replies
-
- wlan connection
- phone
-
(and 1 more)
Tagged with:
-
Hi, So a little bit of background info: I'd like to create a program that could run 0-24 and would do the following: receive a Facebook message with a YouTube URL, download the video and finally send it back as a reply. It is because my data plan includes unlimited data for Facebook, which I never use, and this way I could get unlimited YouTube. I've only started programming recently, and I can use C++ and C#, although I'm not very fast or experienced in either of them. After a bit of searching, I found that the Messenger API uses Javascript, but I haven't used Java or Javascript ever. So: Is there already a bot/program that could do this (kinda like IFTTT)? If there isn't where how I start writing this program, should I use C# or should I learn Javascript? Thanks in advance!