Search the Community
Showing results for tags 'c'.
-
I can't seem to figure out exactly what standard of USB my USB type c port on my computer is. The reason I would like to know is so I can make a decision on what kind of dingle to get or if possible get a cable to go from USB c to USB b for a separate hub (on a monitor for example)
-
Quite simply I want/need to learn how to code in C. And I am wondering a few things, A) is there any guides etc. which can be used in order to start learning which are free, as me no money B) any hints tips or tricks I should know about before I start which will be helpful to know C) is there any other helpful information I should know before I start. Thanks in advance
-
Sup So next year I will go to university and stay in a new apartment room every year. I own a very capable desktop gaming pc and I will buy a cheap gaming laptop for on the go and class usage. The thing is that I want to be able to switch to my more powerful desktop when I am in my room to work on projects etc. The room I'll stay in won't have a good internet connection though... It only comes with a slow-ish WiFi connection with no ethernet support. My PC doesn't have a wireless card. I want a network setup which allows fast communication between my desktop and laptop and give my desktop internet connection. Any recommendations for a simple, reliable and fast network that will suit my needs?
-
hello, I am learning to program with c and im stuck with this problem. I have this file detale.txt, and I need to set its first number as a vareable. After that I have to use its value for 3 different array sizes(2 ints 1 float). Also I have to take vlaues of these 3 arrays from file (first array- first column (exept that first value used for setting arrays size), 2 array- 2nd column, 3rd array- 3rc column. I would be greatfull for help. Im noob programer :D..
- 5 replies
-
- c
- programing
-
(and 2 more)
Tagged with:
-
So I have the grove starter kit for the Arduino Uno (https://www.seeedstudio.com/Grove-Starter-Kit-for-Arduino-p-1855.html#) and have started to play around with it, but what I am trying to do now it when you click the button that comes with the starter kit it changes the text on the LCD screen that comes in the starter kit also. I have tried to get it working but I can't. My Code: #include <Wire.h> #include "rgb_lcd.h" rgb_lcd lcd; // constants won't change. They're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("System Enabled!"); } void loop(){ } void activate(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == HIGH) { lcd.print("System Disabled!"); } if (buttonState == LOW) { lcd.print("System Enabled!"); } } Thanks!
-
here is the task you get this (array a): -1,2,4,-3,-2,8,-4,5. you have to make a new array in which the numbers will be placed from smallest to biggest
- 7 replies
-
- programing
- c
- (and 4 more)
-
I have a problem with a project for Uni. I know this has been done many times before and there is probably a more optimal way but I want to get there largely by myself.The problem currently is that if I set the scope(the program searches for prime numbers between 2- ... <-- this i called 'obergrenze'). if that upper boundry is set to roughly 1 million - haven't tried to many different values but 100k works - it crashes but idk why. Might this be a memory limitation? I have 4GB of VRAM but the program only uses about 30-35MB. The task is to progrma something that finds all prime numnbers from 2- 100 000 000 and then trim for speed which i have not been able to do yet. Some notes: Sry for all the german variable names. the 'int integer' is just a test and 100% irrelevant. I first fill the array in which the position simbolizes the number - NOT its value - with -1 and then edit these to 1 for a prime number or 0 for non prime. In the end every number should be either 1 or 0. I separately count up how many primes i got and how many non for some controllability. Should work until there but it is for some reason not scalable. #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #include <math.h> int main() { //Sieb des Erathostines int obergrenze = 200000; int zahlen[obergrenze - 2 + 1]; int i, j; int posAnzahl = 0, negAnzahl = 0, summe = 0; int integer = 2000000000; //array befüllen for(i = 0; i < obergrenze; i++) { zahlen[i] = -1; } //Schleife vom niedrigsten bis zum höchsten sinnvollen Wert for(i = 2; i <= obergrenze; i++) { if(zahlen[i - 2] == -1 || zahlen[i - 2] != 0) { for(j = i; j <= obergrenze; j = j + i) { //printf("\n Kontrolle j=%d",j); if(j == i) { zahlen[j - 2] = 1; posAnzahl++; // eine Möglichkeit separat zu zählen }else{ //if(zahlen[i]%j == 0) if(zahlen[j - 2] == -1) { zahlen[j - 2] = 0; negAnzahl++; // gehört zur Möglichkeit separat zu zählen und dient Kontrolle } } } j = 0; }else{ //if(zahlen[i] == -1 || zahlen[i] != 0) } } printf("\n Anzahl der Primzahlen:%d\n Anzahl der NICHT-Primzahlen:%d\n Gesamtmenge der Zahlen %d gleich obergrenze: %d?", posAnzahl, negAnzahl + 1, posAnzahl + negAnzahl + 1, obergrenze); for( i = 0; i < obergrenze - 2 + 1; i++) { if(zahlen[i] == -1) { printf("\n Es wurden nicht alle Zahlen bearbeitet! zahlen[%d]", i + 2); }else{ //if(zahlen[i] == -1) summe = zahlen[i] + summe; } } return(8); } EDIT: To be clear please don't suggest me just copying something else. I would very much prefere to find out and solve what the problem is I have right here. The maximum value the program works with is obergrenze=518132;
- 27 replies
-
- c
- prime number
-
(and 1 more)
Tagged with:
-
My home build NAS server will not startup, its newly build and will not start for the first time. Hardware: Moterboard: Intel server board S5520HC Ram: 48 GB ddr3 ram PSU: Corsair HX750i GPU: GeForce GT 710 mini CPU: 2x Xeon X5660 CPU cooler: 2x Intel BXSTS100C HDD: 3x WD 5TB RED NAS SSD: 1x Samsung 750, 250gb When i turn it on, all fans start og run, they drives start spinning. The problem is that no video output starts op, not on the onboard and not on the GPU. i have tried both HDMI and VGA. What can be the problem?
-
Hi, Thanks for helping me out, if you're wondering why I'm not posting on stack overflow, it's because I have a cool down for some reason. Here's my code: Okay, as you can probably see. I'm trying to get my program to loop back to the beginning whenever K is turned into something other than 0. Any loops I try result in it either not working or a crash. I think I'm missing something really essential from a while loop, and I can't seem to think what it is. Thanks for helping me out, and sorry if I explained this poorly.
-
Guys I have a question my recent built is core i5-9400F RTX 2060 16GB Corsair DDR4 2666mhz 500gb wd ssd now is this build enough to play Ghost recon Breakpoint on high or very high settings ?? i played beta this week and it was awfully lagging ... some people had no issues at all on 1080pixels 75fps .. and some are saying that my build is weak... I don’t understand ... recommended cpu is core i7 6700k .. is the game broken or my build is not good enough ???
- 23 replies
-
- gaming
- ghostreconbreakpoint
-
(and 2 more)
Tagged with:
-
So what i've found is the tutorial i've been following and modifying doesn't improve itself. My population seems to keep hitting either a local minimum or it outright doesn't improve but the fitness keeps going up. I was wondering if anyone would be able to have a look, point me in a direction for more resources on genetic algorithms or on the project itself. An overview of the project is to simply get the population to move around a map and find an object eventually i want to put this into a neural network so it can predict player movements. Tutorial : https://www.youtube.com/watch?v=1oXr16Tdfvo Project :https://wetransfer.com/downloads/16079695138c98a89d7e80aea8cfca2820190515023441/aa04d9
-
Hi there, currently struggling with C programming with command line arguments, header file, and how can I call them here. To be honest, still gets a lot confused for even the code that I write. I've got some progress already, here: (some in Indonesians, but should not be a problem since it's only the output texts.) complex.h header file #ifndef COMPLEX_H_INCLUDED #define COMPLEX_H_INCLUDED complex getcomplex(char *input); mag(complex a); phase(complex a); complex sum(complex a, complex b); complex substract(complex a, complex b); complex multiply(complex a, complex b); complex divide(complex num, complex denum); #endif // COMPLEX_H_INCLUDED complex.c (still incomplete though, I struggled to how can I extract the real and imaginary numbers out of a string when using command line arguments, so I can do the operations.) #include <stdio.h> #include <complex.h> #include "complex.h" typedef struct complex { double real; double img; char input[20]; } complex; struct complex a,b,c; complex getcomplex(char *input){ char input[20]; complex a,b; scanf("%s",&input); sscanf(input, "%lf+%lf", &real, &img); } complex sum(double real, double img){ complex c; c.real = a.real + b.real; c.img = a.img + b.img; printf("Hasil operasi penjumlahan bilangan kompleks = %d + %di", c.real, c.img); return (c); } complex substract(double real, double img){ complex c; c.real = a.real - b.real; c.img = a.img - b.img; printf("Hasil operasi pengurangan bilangan kompleks = %d - %di", c.real, c.img); return (c); } complex multiply(double real, double img){ complex c; c.real = a.real*b.real - a.img*b.img; c.img = a.img*b.real + a.real*b.img; printf("Hasil operasi perkalian bilangan kompleks = %d + %di", c.real, c.img); return (c); } complex divide(double real, double img){ complex c; x = a.real*b.real + a.img*b.img; y = a.img*b.real - a.real*b.img; z = b.real*b.real + b.img*b.img; printf("Hasil operasi pembagian bilangan kompleks = %d + %di", c.real, c.img); return 0; } For getcomplex() tho, I've got it from my previous topic in this forum, here. It works when I'm separately compile the extract program on another file, but I'm confused how to implement to the program here. With struct, and pointers, but to be honest I'm still confused with pointers. main.c #include <stdio.h> #include <string.h> #include "complex.h" int main(int argc, char *argv[]) { if (argc < 4 || argc > 5) { printf("Tolong masukan minimal 4 argumen. //ex. namafile arg1 arg2"); return 0; } char ch,p,q,r; p = argv[1]; q = argv[2]; r = argv[3]; switch(ch){ case 'sum': sum(getcomplex(q),getcomplex(r)); break; case 'substract': substract(getcomplexA(q),getcomplexB(r)); break; case 'multiply': multiply(getcomplexA(q),getcomplexB(r)); break; case 'divide': divide(getcomplexA(q),getcomplexB(r)); break; } } I can somewhat get the main.c albeit working for the 'if' statements. But not on the case one (or did I actually using the wrong one?) In case you're wondering, the job is make a complex number operations program that using command line arguments. For example, I'm running command prompt from the program folder, then input "main.exe add 3+1i 2+3i" to the command prompt so the output can be the result of the sum of the complex number. Needs your guys help and references, quick reply will be very appreciated, I'm already stuck at this for be like a day.
-
Extract Two Float/Double Numbers Out of a String on C?
TukangUsapEmenq posted a topic in Programming
As the tittle says, it is. Needs you guys references for extracting two float numbers (or integers, nah any kind of number) out of a string. Example, I type -2.2+3i and I need both of the real and imaginary number to be separated so I can use them for the operations. Kinda new in programming, just by 2 months learning about C on campus, so yeah. I'm stuck at here searching at everywhere. Example (for program using command line argument tho): (it's in Indonesian but... You'll get the point from the inputs and outputs.) Y'all help will be nicely appreciated, as deadline is 2 days away. (not only this tho, still a lot job to do) -
okay so they are offering back to school pre-built system for 620USD or 9million IDR ( my country currency) thus include: Ryzen 2400G MOtherboard AB450 ( they didnt mention about the brand ) Rx 570 4GB 8 gigs ram ( 2400mhz ) 120gb ssd + 1TB HDD PSU 450w bronze 80+ Digital aliance WIn 10 with Mousepad and free mecha keyboard. For 620$ what do you guys think? fyi this is the most trusted local brand and very popular
-
#include <stdio.h> #include <stdlib.h> #include <time.h> #define HAND_SIZE 13 #define DECK_SIZE 52 int table[4][13]; //desk of cards // s 0-12 h 13-25 d 26-38 c 39-51 //suit n/13 //rank n%3 //shuffle //shuffle mvoe to temp //temp deck at n1 //deck at n1 deck at n2 //deck at n2= temp //print out in list // deal right // top to bottom every get 13 //selection sort int sort(int p){ printf("%d\n",p); int pos=0; for (int i=0; i<12; i++) // finding minimum element (n-1) times { pos = i; for (int d = i + 1; d < 12; d++){ if (table[p][pos] > table[p][i]){ pos = d; } if (pos != i){ int t = table[p][i]; table[p][i] = table[p][pos]; table[p][pos] = t; } } } return 1; } int main(void) { srand(time(NULL)); printf("Bridge\n"); int deck [52]; char suits[]={'s','h','d','c'}; //shuffle for(int i=0; i<DECK_SIZE; i++){ deck[i]=i; } { for (int i = 0; i < DECK_SIZE; i++) { int j= rand()%52; int temp = deck[j]; deck[j] = deck[i]; deck[j] = temp; } } //deal 13 times int c=0; int h=0; while( c<52){ for(int p=0; p<4; p++){ table[p][h]=deck[c]; c++; } h++; } //sort each hand highest to lowest for(int play=0; play<4; play++){ sort(play); } printf("hi\n"); // test print for(int f=0; f<4; f++){ for(int i=0; i<13; i++){ printf("%d ",table[f][i]); } printf("\n"); } //print out hand printf("\n\t\t\tS"); printf("\n\t\t\tH"); printf("\n\t\t\tD"); printf("\n\t\t\tC\n\n"); printf("S"); printf("\t*********"); printf("\tS bob\n"); printf("H"); printf("\t* N *"); printf("\tH test\n"); printf("D"); printf("\t*W E*"); printf("\tD hello \n"); printf("C"); printf("\t* S *"); printf("\tC hi \n"); printf("\t*********"); printf("\nS"); printf("\nH"); printf("\nD"); printf("\nC\n"); return 0; } my primary issues currently is I can't get my section sort working right and the deal section of code isn't working ether. I'm new to C while I've done similar work in java I left it all on my high school computer so I can't go back to reference it. bad bracket placement.
-
Hi, i am attempting to convert a text box on a winForm into string so i can display the results on a message box. i have treid to convert to string using the code seen bellow however to no avail. anyone got any tips? surname = Convert.ToString(textBoxText.Text);
-
Hi, I am struggling to find a way to take a picture with a webcam since i ditched emgucv due to its memory leak in the capture class. Does anyone know a good library?
-
As the tital says how do I load an image in C# using .NetStandard. The aim of the function is just to confirm the file is definately a image, be it png, bmp, ico, tiff or webp. Also because it makes it easier for me if it can only use currently inbuilt tools and no NuGet files that would be swell as I plan to build this as a libary to use this externally in other code I am running to check if files have the correct file extension EDIT: Because I forgot to say this before and a number of people have suggested it. I am readeding the magic bytes (the bytes that say Hey I'm a PNG etc.) but in an attempt to error check that these are deffinately correct I want to load it as an image. The entire point of the code is to detect file types, more specifically the file types of files in a chache which do not have file extensions and by just checking for the magic bytes does not always work correctly, e.g. you get mp4s which aren't mp4s, or pictures which aint pictures etc.
- 12 replies
-
- c
- visual studio
-
(and 1 more)
Tagged with:
-
Hello all, I am using a raspberry Pi 4B 4GB with Raspbian and Mono C#, I am looking for a Speech API to replace System.Speech since its not supported in Mono, anyone have any API for a speech to speech for my project?
-
hi all. i am making a new desktop app, which involves extensions. since i haven't the time to create a scripting language or implementing an existing one, i've chosen to call specific methods of all dlls in a specific folder. so i coded a simple extension that implements Discord RPC. but when i try to run it, a MissingMethodException gets thrown. Here's the code Main assembly: public void InitializeExtensions(string extpath) { foreach (string dll in Directory.GetFiles(extpath, "*.dll")) { Assemblies.Add(Assembly.LoadFile(dll)); } List<Assembly> ToRemove = new List<Assembly>(); //All the assemblies that cannot be initialized will be removed from the list of assemblies foreach (Assembly DLL in Assemblies) { foreach (Type type in DLL.GetExportedTypes()) { try { var c = Activator.CreateInstance(type); type.InvokeMember("Initialize", BindingFlags.InvokeMethod, null, c, new object[] { this }); } catch (MissingMethodException ex) { ToRemove.Add(DLL); MessageBox.Show(String.Format("Could not initialize the extension {0}: MissingMethodException {1}, Path.GetFileName(DLL.Location), ex.Message), "YouTubeDesktop - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } foreach (Assembly a in ToRemove) { Assemblies.Remove(a); } } And the DLL //using main assembly static Form1 Form1; public static DiscordRpcClient Client; public static void Initialize(object[] args) { Form1 = (Form1)args[0]; Client = new DiscordRpcClient("My_ID"); //Set the logger Client.Logger = new ConsoleLogger() { Level = LogLevel.Warning }; //Subscribe to events Client.OnReady += (sender, e) => { Console.WriteLine("Received Ready from user {0}", e.User.Username); }; Client.OnPresenceUpdate += (sender, e) => { Console.WriteLine("Received Update! {0}", e.Presence); }; //Connect to the RPC Client.Initialize(); }
-
I am looking for an C# Ui that works on linux where you can drag and drop Ui elements like on Windows Forms
-
Hi, I am trying to write a program that will print out the contents of a file. I also wanted to try making the program take an argument in the command line. Here is my code: #include <stdio.h> int readFile(char *infile) { int num; FILE *fptr; fptr = open("/home/students/hansong5/crypter/%c", infile, "r"); if(fptr == NULL) { printf("Error opening file"); } fscanf(fptr, "%d", &num); fclose(fptr); return num; } int main (int argc, char *argv[]) { printf(readFile(argv[1])); return 0; } I am having a number of problems. The first being that this code does not compile without warnings or errors, as shown below: For some reason, when I try to read the file using fopen, I get the error: "too many arguments". I am trying to specify the path name by putting the %c at the end of the path and specifying that it should use the first argument in the command as the path name. Then, I get a warning about making a pointer from an integer when using printf. Should I define a variable outside of the printf statement with the function instead of passing the function inside of the printf statement? The second problem is that when I try to run the code with warnings I get a segmentation fault. I believe that is just because I am misusing the pointers in my code but I'm not sure how to go about fixing this. Any help would be greatly appreciated! Disclaimer: While in my filepath you can see "student" as one of the directories, this particular project is not a homework assignment. I program mostly on a redhat server that the university provides us. I am trying to learn about reading and writing files and writing C programs with arguments on my own time to work on a crypter. I always specify whether or not the code I am sharing is part of a homework assignment because helping with homework may go against some people's ethics. I have post history with homework assignments I've worked on as proof of this.
-
I'm creating an int to char function, but struggling with parameter passing char num_to_char(short Number, int POS) // Less than 100,000 { char Num_char[5] = {'0','0','0','0','0'}; while (Number > 10000) { Num_char[0]++; Number = Number - 10000; } while (Number > 1000) { Num_char[1]++; Number = Number - 1000; } while (Number > 100) { Num_char[2]++; Number = Number - 100; } while (Number > 10) { Num_char[3]++; Number = Number - 10; } while (Number > 1) { Num_char[4]++; Number = Number - 1; } return Num_char[POS]; calling back voltage[0] = num_to_char( Number, 0); voltage[1] = '.'; voltage[2] = num_to_char( Number, 1 ); voltage[3] = num_to_char( Number, 2); voltage[4] = num_to_char( Number, 3); voltage[5] =num_to_char( Number, 4); voltage[6] = 'V'; Any help?
-
I am writing a program in C that checks for prime numbers within a range of numbers. The program seems to be working fine, but there are a couple problems that I haven't been able to figure out. Here is the code: #include<stdio.h> main() { int counter = 0; int lower_bound, upper_bound, num_counter, i; printf("Lower bound?\n"); scanf("%d", &lower_bound); printf("Upper bound?\n"); scanf("%d", &upper_bound); num_counter = lower_bound; while (num_counter <= upper_bound) { if (num_counter <= 1) { printf("%d", num_counter); printf(" is not prime\n"); break; } else if (num_counter > 1) { for (i = 2; i <= num_counter / 2; i++) { if ((num_counter % i) == 0) { printf("%d", num_counter); printf(" is not prime\n"); break; } if ((num_counter % i) != 0) { counter = counter + 1; printf("%d", num_counter); printf(" is prime\n"); break; } } } num_counter = num_counter + 1; } printf("%d\n", counter); int num_range = upper_bound - lower_bound + 1; printf("%d\n", num_range); float prime_density = counter / num_range; printf("%f\n", prime_density); /*printf("Over the interval from "); printf("%d", lower_bound); printf(" to "); printf("%d", upper_bound); printf(" inclusive, the prime density was "); printf("%f", prime_density);*/ } The first problem I have is that the program does not like the number 3 as a lower_bound value, here is the output when I try a range from 3 to 6: Lower bound? 3 Upper bound? 6 4 is not prime 5 is prime 6 is not prime 1 4 0.000000 It will function almost perfectly but will not print out anything for 3 or add one to the counter. The next problem I have is with a float called prime_density. I have the string stuff commented out so I could try and figure out why it kept printing out 0.000000. As you can see above, the result for prime_density should be 0.25 if the counter is at 1 and the num_range is at 4, but it just prints 0.000000 every time, even with number ranges that don't include 3: Lower bound? 7 Upper bound? 10 7 is prime 8 is not prime 9 is prime 10 is not prime 2 4 0.000000 Any help or advice to fix this would be greatly appreciated!
-
Simple question I am reading a line from a text file which contains \n's and when I print the string it doesn't print the \n as a new line but as "\n" how do I change this into a newline. Line 1 is what I get, Lines 2-5 is what I want. (I did this manually to get the desired output) EDIT: Just found out why it's doing it, it is turning /n into //n so I need to find //n and replace it with /n, any suggestions on how to do this
- 2 replies
-
- c
- visual stuido
-
(and 1 more)
Tagged with: