Search the Community
Showing results for tags 'c'.
-
Hey i have to write a little console Porgramm in C# for school that count up to your input. So when the input is 5 for example the result should be like this: 0 1 2 3 4 5 and so on... can somebody help me how i get this? Thanks!
-
Hi, I´ve got a problem and I need your help! I have smartphone with a Usb C connector and a bumper around the divice, but now my problem is that the Usb C connector out of the box is to short... Are there any adapters? From Usb C (Male) to Usb C (Female) with a long Usb C connector??? Hope you can help me.... Enki
-
Hello everyone, I am doing an exercise that goes as follows: Write a program that creates a child process and establishes with it a communication channel through a pipe. The parent process reads an integer and a string from stdin and sends both through the pipe. The child process should read those values from the pipe and print them. a. Solve the exercise by first sending an integer and then a string in two separate write operations; b. Solve the exercise by using a structure to send both values in one write operation. So far I have this: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #define BUFFER 50 static const int LEITURA = 0; static const int ESCRITA = 1; static const int A = 0; //Question A static const int B = 1; //Question B struct build { int n; char string[10]; }; static int getPrompt(int mode, char* s,char *buffer, int size, struct build build1){ // Get line with buffer overrun protection. if (s != NULL) { printf ("%s", s); fflush(stdout); } if(mode == A){ long n; fgets(buffer,size,stdin); sscanf(buffer,"%d",&n); printf("\nString: \n"); fgets(buffer,size,stdin); return n; }else { fgets(buffer,size,stdin); build1.n = (int) strtol(buffer,&buffer,10); char *ptr = build1.string; ptr = buffer; } return 0; } int main() { int ds[2], status; pid_t pid; char buffer[10]; struct build build1; //Se bem sucedido cria o pipe if(pipe(ds) == -1) { perror("Pipe failed."); return -1; } //Se bem sucedido cria um processo filho pid = fork(); if (pid < 0){ perror("Process failed:"); exit(-1); } //Codigo Pai if(pid > 0){ //Fechamos o que não é utilizado close(ds[LEITURA]); int questao=2; while(questao!= 0 && questao!=1){ printf("Question number: \n"); scanf("%d", &questao); } if(questao==A){ //Escrevemos no pipe o pretendido int k = getPrompt(A,"Number: ", buffer,sizeof(buffer), build1); write(ds[ESCRITA],&k,sizeof(k)); write(ds[ESCRITA],&buffer,sizeof(buffer)); }else{ //Escrevemos no pipe o pretendido getPrompt(B,"Number and String: ", buffer,sizeof(buffer), build1); printf("%d , %s\n", build1.n,build1.string); } //write(ds[ESCRITA],); //Codigo filho }else{ char buffer_output[BUFFER]; char buffer_copy[BUFFER]; int n=0; close(ds[ESCRITA]); while(read(ds[LEITURA], &buffer_output, sizeof(char))>0){ *(buffer_copy+n) = *buffer_output; n++; } *(buffer_copy+n) = '\0'; char *ptr = buffer_copy; int m = (int) strtol(ptr,&ptr,10); printf("Number: %d\nString: %s", buffer_copy); close(ds[LEITURA]); exit(1); } return 0; } Some of the comments are in portuguese. Now I am missing some things but before I do them I would like to know how to solve the current issues. 1->fgets does not wait for input and just runs through (on function getprompt, sscanf seems to wait for input but I am not sure this is correct so I only had it there once for testing) 2-> result of strtol and way I am implementing it (not sure if it is the right thing to do here) 3-> If I do strtol on a char array does the number get taken out? Or does the pointer advance to the first non digit?
-
hey guys I'm just creating an 8 ball application and when i debug i get a warning saying the process cannot access the file because it is being used by another process and the file is locked by: (as seen in the image below) I have no idea why I'm getting this problem, any help will be appreciated, thanks .
-
I'm writing a DB management app in c# using uwp and mvvm-light and I can't display a default selectedValue in my combobox without opening it and manually selecting one first. Here is my view : <ComboBox x:Name="editCategory" Header="Category" ItemsSource="{Binding Categories}" SelectedValue="{Binding CategoryCode, Mode=TwoWay}" SelectedValuePath="Code" DisplayMemberPath="Name"/> Here's my ViewModel : private ObservableCollection<Category> _categories; public ObservableCollection<Category> Categories { get { return _categories; } set { if (_categories == value) return; _categories = value; RaisePropertyChanged("Categories"); } } private int _categoryCode; public int CategoryCode { get { return _categoryCode; } set { if (_categoryCode == value) return; _categoryCode = value; RaisePropertyChanged("CategoryCode"); } } And my model : class Category { public int Code { get; set; } [Required] public string Name { get; set; } } I can display the different values when opening the combobox, when I select a value, it displays it correctly when the combobox is closed. I know the binding is working because if I set a breakpoint in the setter of CategoryCode in my ViewModel, it shows the correct updated value. The problem is that when I load the page, the default value is not selected when it should display the Category.Name of the item where Category.Code = CategoryCode Please help me if you can, I've been searching for hours, and nothing I could find has helped me so far Link to my StackOverflow question
-
Hello, I am programming a game for a school project. I have just dove in to the C# and Unity. My problem is transfering score(basically players position) from the level scene to the menu. So far I got this. Be aware that I am very unfamiliar with C# commands and its syntax. using UnityEngine; public static class StaticScrScr : MonoBehaviour { private static int score; public static int Scoreset(sc) ## not sure how to properly call this method { set this se as well as get seem out of place but its what I found on the internet. I assume that it is just a general code explanation but I don't know what am I supposed to put instead of them. { score = sc; } } public static int Scoreget() { get ## this se as well as get seem out of place but its what I found on the internet. I assume that it is just a general code explanation but I don't know what am I supposed to put instead of them. { return score; } } } This is my static script its where I save score value. using UnityEngine; using UnityEngine.UI; public class Score : MonoBehaviour { public Transform player; public Text scoretxt; private float poz; // Update is called once per frame void Update () { poz = player.position.z.ToString("0"); scoretxt.text = poz; StaticScrScr.Scoreset(poz); } } This i my score script where I update score on game scene in real time and I save it to the static script using UnityEngine; using UnityEngine.UI; public class updatingscore : MonoBehaviour { public Text scoretxt; void Start () { scoretxt.text = StaticScrScr.Scoreget(); } } This is a script that I atached to the text on game menu that should draw the score value from static script and change text whenever the menu is loaded. In my High school we are programming in python but this is for my final Assigment. So I am aware of how some things in coding work but am very unfamiliar with both C# and unity.
-
I have been webdesigning for almost 5 years and C programming Arduinos and ESP for almost a year, so i decided to enter the realm of hardcore programming and start with loading a grapghic library GTK+ on my IDE. I use 2 IDE, Dev C++ and Visual Studio 2017. But for some reason, i can't make the library work. There is always some kind of issue somewhere. I would really appreciate if someone can answer me to quesions: 1. Why isn't there a decicated C file/project option in visual studio (when C is one of the most important languages)? 2. Why is the installation of libraries so complicated? Can't there be some kind standard? I mean, can't i just download the library? And install it directly from the IDE itself? 3. If GTK+ one of the major Graphic libraries for C, C++, Python, C# , why is it's webpage so crappy? Why are the tutorials outdated?
- 10 replies
-
- c
- visual studio
- (and 4 more)
-
Hey guys, I'm making a game for a project of mine and when i switch scenes to the level from the start screen, in split screen mode you can see the text in the background (pictures below, you can see the start screen in the small gap between the 2 camera) if anyone can help i appreciate it
-
Hello everyone, I have an exercise where I need to read 20 names (user input) to a vector dinamically created and list all of those who don't start by the letter 'A' So far I have this, though the check for first letter A isn't working yet #include <stdio.h> #include <string.h> #include <stdlib.h> #define TEST "A" void print_vector(char** vec,int n){ int i; const char* ptr = TEST; for(i=0;i<n;i++){ if(strchr(ptr,vec[i]!=NULL)){ printf("%s\n", vec[i]); } } } int main(){ char **a = malloc(20 * sizeof *a); int i; if (a){ for (i = 0; i < 20; i++){ a[i] = malloc(40 * sizeof *a[i]); printf("String a introduzir\n"); scanf("%s",a[i]); } } print_vector(a,20); } Is there a better way to do this? Does this even make sense?
-
Hey everyone! Just wanted to see if anyone had a good recommendation for a USB-C HUB/Dock. Instead of plugging and unplugging like 5 usb devices I want to get a dock/hub to attach to the back of my desk and plug everything into that so I only have a single USB-C cable running to my desktop. I have the Ultra Z170-X Gaming MOBO (Rev 1.0) and it has a Thunderbolt 3.0 usb-c port so I want to take advantage of all the bandwidth Thunderbolt is capable of. Let me know if you have any other solutions or any recommended hubs! - I tried buying on on amazon but it constantly went in and out, like it was losing power. So preferably a hub that also connects to the outlet for a good source of power would be nice, otherwise I don't think a little hub can power my keyboard, mouse, camera, mic, ect. all at once consistently.
-
Hello, Specs: Ryzen 5 1600 Cryorig H7 CPU Cooler EVGA 1060 6GB SC (Not purchased yet, but interested in this card) Fractual Design Meshify C I'm assembling a new build in the Meshify C, and looking to replace the front fan with two 140mm fans to increase the airflow. The Corsair ML140 PRO fans and the Noctuas (both normal and industrial versions) are my two choices at the moment. What fans would offer the best airflow performance with the least amount of noise, and would the single 120mm exhaust be sufficient for the build?
-
Before I get started, please note that I am doing this as a part of my classwork. If that bothers you, maybe just give me hints instead Hi, I have just started learning some C++ and am trying to create a program that will ask a user for a single digit integer (1 through 9), print it out, and ask again until the user inputs the character "x" The output I want would look like this: Enter a non-zero integer (or x to quit): 7 Enter a non-zero integer (or x to quit): 3 Enter a non-zero integer (or x to quit): -5 Enter a non-zero integer (or x to quit): -1 Enter a non-zero integer (or x to quit): x Program stopped. You entered 4 integers. 2 of the integers were positive. 2 of the integers were negative. The largest value you entered was 7. The smallest value you entered was -5. The sum of the 4 integers was 4. So far, my program looks like this, but it does not run. I am having problems with the variable type. #include <iostream> using namespace std; int main() { char user_input; cout << "Please enter a number (or x to stop): \n"; cin >> user_input; if (user_input == "x") { cout << "Program stopped"; } else { cout << "Input: " << user_input << "\n"; } return 0; } Any help on this? Should I use a different loop other than if? Any help would be appreciated.
-
Hello I am a junior and college and I've recently been looking into the fact that I need a way to show off programs I write (git) but now I'm just kinda looking for ideas as far as what looks good and what are some projects in general that I could do that will fill up some free time and keep me off my normal games. (Please don't recommend for me to build a game :))))))))))) ) listed in the tags is my main points of focus as far as what Id like to show case and what I'm most sufficient in (but always looking to learn more(but fuck java, java is boring)). Anyways any pointers, tips, or suggestions will be appreiciated. Thanks. Tldr: I'm looking for a project (not a game )I can work on in some spare time that I can also show case on my git.
-
Hi. I'm really new to programming. I'm still 15 y.o and I wanted to start learning programming since it attracts me. Any guide on how I should start? Let's just say I know nothing about programming and C language. I want to learn how to code using C language. Any suggestions? I recently watched a video on how to use codeblock but I still don't get on how it works or why it works that way.
-
Thought I would post part of a funny convo I had with one of my friends about programming with C. Don't know about you guys but me and everybody I know hates it..
-
Hey guys I tried to make my program keep track of how long it takes to completely finish, but when it is run it says something stupid like the program only took .000594 seconds. Does anyone have any tips as to why it is doing this? I'm also having trouble with srand not making it super random but I think I might be able to find out how to do that. Any advice is much appreciated.
-
Hi all, For my year 12 (Final year) of high school i'm planning on making a IT oriented business management software, I can code well in c# and I am also making an sql server to hook it up to but I just need some help brainstorming what I should put in the software, I was thinking of a job system where a client can enter a job from an external source and you can view your employees progress as well as complete invoices and manage an inventory (this is essential) but that is the main overview I would very much appreciate some help, Kind Regards Hanno
- 9 replies
-
- code
- programming
-
(and 3 more)
Tagged with:
-
I am working on a quiz for my school coursework and i cantI can't seem to figure out how to get this class iI have made to work with this form. I am making a quiz and when you start the quiz you are brought to a screen that will say what topic number you are on and what the name of the topic is: Pic of topic page (The create user button is a placeholder) but i want the topic to be random each time and the topic number to increment each time you get to the topic page as after you finish on topic it will go back to that page and do the selection again. so far i have this as a class namespace ChemistryQuizMock { public class ChooseTopic { //init variables private string topic_name; private int topic_count; private int random_topic_number; //init topics private string[] topic_list = new string[] { "Chemical Calculations", "Acids And Bases", "Bonding", "Rates Of Reactions", "Metal Extraction", "Exothermic And Endothermic Reactions", "The Periodic Table" }; //get set variables public string TopicName { get; set; } public int TopicCount { get; set; } public int RandomTopicNumber { get; set; } public string[] TopicList { get; set; } //constructor public ChooseTopic(string TopicName, int TopicCount,int RandomTopicNumber,string[] TopicList) { TopicName = topic_name; TopicCount = 1; RandomTopicNumber = random_topic_number; TopicList = topic_list; } //pick a random topic from the list public void PickRandomTopic() { Random rTopic = new Random(); RandomTopicNumber = rTopic.Next(0,TopicList.Length); } //turn to list remove item and return to array public void RemoveTopicFromList() { var list = new List<string>(TopicList); list.RemoveAt(RandomTopicNumber); list.ToArray(); } //increase topic count public void IncreaseTopicCount() { TopicCount++; } } } and this is the form cod namespace ChemistryQuizMock { public partial class TopicPage : Form { public TopicPage() { InitializeComponent(); CenterToScreen(); } } } I'm very new to c# and don't know how to make it so i can use this class in the form and all i really know is it has to be a class because the array of topics has to be in a class as topics are removed after they have been done.. any help??
-
Hi, I'm trying to decrypt a ".txt" file using C language (cipher method). I keep getting loads of errors during compiling. Can someone please help me? Thanks! Code: #include<stdio.h> #include<stdlib.h> #define MAX_SIZE 256 int main(int argc, char *argv[]) { *argv=[1], argv=[2]); FILE *in_file, out_file; in_file= fopen(argv[1], "r"); out_file= fopen(argv[2], "w"); void counter() char str[MAX_SIZE]; int i, len; int freq[26]; gets(%i); len = strlen(str); for(i=0; i<26; i++) { freq = 0; } for(i=0; i<len; i++) { if(str>='a' && str<='z') { freq[str - 97]++; } else if(str>='A' && str<='Z') { freq[str - 65]++; } } char data[50], temp; int key, count; void shuttleSort(int a[], int n) { int i = 1, j; int temp; while (i < n) { j = i - 1; while (j >= 0) { if (a[j] > a[j + 1]) { temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; j--; } else { break; } } i++; } printf("\n"); printf("\nThe sorted array elements are given below\n"); for (i = 0; i < n; i++) { printf("a[%d]=%d ", i, a); } } void shuttle sort int i, n = 6; int a[] = {15, 8, 17, 12, 38, 19}; printf("\n:: Shuttle Sort ::\n"); printf("\nInput array elements\n"); for (i = 0; i < n; i++) { printf("a[%d]=%d ", i, a); } void caesar_cipher_decryption() { for(count = 0; data[count] != '\0'; count++) { temp = data[count]; if(temp >= 'a' && temp <= 'z') { temp = temp - key; if(temp < 'a') { temp = temp + 'z' - 'a' + 1; } data[count] = temp; } else if(temp >= 'A' && temp <= 'Z') { temp = temp - key; if(temp < 'A') { temp = temp + 'Z' - 'A' + 1; } data[count] = temp; } } printf("\nDecrypted Message:\t%s\n", data); }
-
So my professor assigned a homework that states "your program should accept a list of integers in the range 0-15 and turn on the corresponding bits in an unsigned short to output a result that shows set membership. input 2 3 4 then your output will print 0000000000011100. I'm not entirely sure what turning on the corresponding bits in an unsigned short to output a result that shows set membership means. Could someone just rephrase this for me, I'm having trouble figuring out what this means. He also gives this example but I have no idea what operations are done to get that binary number 3 13 8 14 15 1110 0001 0000 1000
-
Hi all, For my final project at University, it is my task to create and Excel Add-In which allows for users to create a step by step spreadsheet using an Add-In GUI. This will include the background colour, text colour, font type, box sides and any images they wish to add. I've looked into the basics of C#, however I was wondering if anyone had any hints or tips as to how best I can go about creating this, given the Excel Add-In library is nothing like how you would usually use C#. Many Thanks, Dan
-
In a nutshell I have a school project that wants me to convert an entered binary number to a decimal. Program should go something like this: User enters binary number -> binary number is converted one digit at a time -> decimal number is displayed. I am very new to C and programming in general. If you have any tips or snippets of code you could share that would be great. Thanks very much!
-
Im trying to find a usb type c female to type c male extension cable. does anyone know of any because i cant find one anywhere?!?
-
Hello dear Programmers, so im currently taking the cs50 computer science course online on the pset1 (Smart Water). Please don't correct my code, just answer my question otherwise it would be cheating (so answer by saying for ex "you need to start a new line and then multiply 10 with 12 and NOT something like : "write int blabla = blabla ... (so basically do not tell me what code i need to write but do tell me what i need to do. i know very confusing and i'm sorry, english is not my native language.)) This programm is calculating how many bottles of water you use while showering (in minutes). 1 #include <cs50.h> 2 #include <stdio.h> 3 int main (void) 4 { 5 printf("How many mintues do you need to shower? :"); 6 float f = GetFloat(); 7 8 float b = 192 / 16 = 12 (f*b) 9 10 } what i want to do is : in line 8 i am dividing 192/16 and that is 12 so in one minute you use around 12 bottles of water. Now i wanted to multiply 12 with the amount of minutes the user stated above (that's what i tried to do i know my way is wrong tho XD)
-
Hey everyone! I really need advise on buying a PC with my budget of $700 CAD. The main purpose for the PC would be to do Android programming and also some Java developing, which I know will require a good CPU. However, I'm debating between RAM and CPU, here are my two current options Get an i7–4790 (@4.0 Ghz) with 8GB of RAM + 1TB HDD Get an i5–6400 (@3.3Ghz) with 12GB of RAM + 1 TB HDD Anything you would recommend! (Canada only) The i7 is much faster than the i5 and that is what's holding me back. The base clock of the i5 is actually 2.7 Ghz, which is horrible. Whereas the i7 base clock is 3.4 Ghz. I preferably don't want to overclock as it'll create extra heat and noise. Aside from Android and Java programming, I'll probably have causal productivity applications; Office suite, Adobe suite and more for editing videos and images. Please give me any possible advice on buying my developing/programming computer, I would really, really appreciate it!
-
- developing
- android
-
(and 3 more)
Tagged with: