Search the Community
Showing results for tags 'c'.
-
I've created a method which selects all the cells in Excel beginning with a1 and ending when there are no more columns or rows. When a button is clicked, I then want to initiate this so that it selects them, however I am getting an error that I can't return the value. This is what I have: public void selectAllCells(Worksheet activeSheet) { activeSheet.get_Range("a1").EntireRow.EntireColumn.Select(); } private void button1_Click(object sender, EventArgs e) { return selectAllCells; } How do I go about returning the method when the button is clicked.
-
Why do all of the Z170/270 boards have the same number of USB ports/general I/O? Is it all down to the count of USB from the chipset? My previous AMD board had like 12 USB ports, but my current one only has like 6.
- 5 replies
-
- chipsets
- motherboards
- (and 4 more)
-
Hi, I am now considering to buy a Raspberry PI 3 and I heard that Python or C is widely used on it. I have good experience in C# and C++ but python seems to have better IDE and easier to learn. Which one would you choose?
- 12 replies
-
Hey, i'm currently on assemblying an LED-System to my desk and PC. OP of the LED Project And the OP already did the coding part, but I would like to have an Audio sensitive reaction for the LED's. What I'm asking: Is it possible to grab the audio signal (duplicate i asume) and process it in realtime? I think yes. But: is it easy? Sure you can import a libary for Audio Analysis, but it should be easy to handle the libary. Can you suggest an easy one? The GUI was written in C#, Arduino Code can be found in the post from above. What I'm trying to do: Audio Level reactive Spectrum (Volume of Frequency presented by LED's) I don't know what else, but suggestions are welcome To be clear, I'm not that deep into C#, I'm currently more on the Lazarus/Pascal side, which is why I'm asking for simpicity. And sure the data would have to be processed with the CPU, and the data sent to the Arduino. Plan is to do it myself over the 2 week holidays write with the OP some more Thanks in advance!
-
Hello I'm very new in C programming and I have some difficulties. I have create a struct.After some inserts i create a function that store data into a file.Now,I want to read this file and save this data into a struct.How can I do this? Any ideas here would be very appreciated. struct book { char author[MAXSTRING]; char title[MAXSTRING]; int id; struct book *next; struct book *prev; }; struct book *head = NULL; //this my function that save data into a file void save(struct book *head) { FILE *bin_file; char name[50]; printf("\n\nWhat would you like to call the binary file in which the data will be stored?\n"); printf("NB remember to add \".txt\" after your chosen name!!!\nENTER NAME NOW>>"); scanf("%s", name); bin_file = fopen(name, "wb+"); do { //NOTE: include terminating zero in the string output; assumes single-byte chars fwrite(head->author, strlen(head->author) + 1, 1, bin_file); fwrite(head->title, strlen(head->title) + 1, 1, bin_file); char char_id[MAXSTRING]; sprintf(char_id, "%d", head->id); fwrite(char_id, strlen(char_id) + 1, 1, bin_file); head = head->next; } while (head != NULL); printf("Your List have been successfully saved to a File\t (File name : %s", name); fclose(bin_file); } void load(struct book *head) { char ch; FILE *fptr; if ((fptr = fopen("asi1.txt", "r")) == NULL) { printf("Error! opening file"); // Program exits if file pointer returns NULL. exit(0); } ch = fgetc(fptr); while (ch != EOF) { struct book *head = (struct book*)malloc(sizeof(struct book)); fscanf(fptr, "%s %s %d", &head->author, &head->title, &head->id); head = head->next; //printf("%c", ch); ch = fgetc(fptr); } //printf("Data from the file:\n"); fclose(fptr); }
-
Hello have created this function in C Book* AddBook(Book *previous) {......} and although i dont have errors in the code i cannot call it in the main function. Is it even possible to call such a function in main and if even so how? Printf("Thanks Very Much\n");
-
I created a keyboard of sorts that takes in input from two buttons for 0s and 1s and it will translate them once you get to a full byte of data. Then with the third button on the right it will send that character (or command such as backspace) to the computer. Not practical in any way but I was bored and wanted to see what you guys thought of it. I also plan on putting it on some perf board so it isn't so.. Ugly.
-
I understand the difference between passing by reference and passing by value. But i'm really confused on deciding when to pass by reference or when to pass by value. Some functions take in paramters by value where as some functions are passed in by reference, sometimes functions use a mixture of both passing by reference and passing by value. Really my question is how do you know when to pass by reference or when to pass by value. As an example I have this bubblesort program that has a few functions in, as you can see the less_eq and greater_eq pass in by value where as the swap function takes in a mixture, and the bubblesort function is just by reference. Can anyone maybe explain this to me. Thanks I do apolagize if i've worded this poorly. #include<stdio.h> #include<string.h> int less_eq(char x, char y) { return x<=y; } int greater_eq(char x, char y) { return x>=y; } void swap(char *s,int i, int j) { char temp=s[i]; s[i]=s[j]; s[j]=temp; } void bubblesort (char *s, int (*rel)(char, char)) { int i, j; int size=0; while (s[size] !='\0') { size++; } for (i=size-1; i>0;i--) for (j=0; j<i; j++) if(!rel(s[j],s[j+1])) swap(s,j,j+1); } int main() { char str[1000]; char str0[]="CTEC2901 Data Structure and Algorithms"; strcpy(str, str0); printf("Original: \'%s\'\n",str); bubblesort(str,less_eq); printf("Ascending: \'%s\'\n",str); strcpy(str, str0); bubblesort(str,greater_eq); printf("Descending: \'%s\'\n",str); return 0; }
- 8 replies
-
- c
- passing my reference
-
(and 4 more)
Tagged with:
-
So I have been teaching my self C for the past couple weeks during free time between classes, but I have yet to use a desktop IDE/Compiler. I have instead been writing my short little test programs on repl.it , and while it works well for simple stuff, I want to move on to something more complex. Which IDE do you recommend me using? I would use visual studio community, but does it support C?
-
http://arstechnica.com/information-technology/2016/10/tfw-an-obituary-you-wrote-five-years-ago-goes-viral/ In October 12, 2011, the creator of C, Dennis Ritchie, passed away. I suppose since this was within a week of Steve Jobs' death, the man never really gotten much attention. But this is the guy who co-created the basis of modern day programming. It's probably harder to list widely used programming languages that didn't have some influence from C. Oh well, at least the power of social media (according to the article) he's getting the recognition he deserves.
-
Right I have this program that allows a user to specify how large an array should be. In the variable k. Then it should ask the user to input and scan the values of the array. This part of my program works fine, however I want the program to also print out the completed array, after the scanner has inputted all of the users values of the array. Not during, which is what it currently does. #include <stdio.h> #include <stdlib.h> int main() { int k; //variable to hold the size of the array int *array; //points to a memory address int i, j; //counters to populate and display the array printf("Enter the size of the array: "); scanf(" %i", &k); //scans in the size of the array array = (int *) malloc( k* sizeof(int)); for (j = 1; j <= k; j++) { for (i = 1; i <= k; i++) { printf("Value at postion %i: ", i); scanf("%i", &array[i]); } printf("%i\n" ,array[j]); } if (!(array = (int *) malloc(k * sizeof(int)))) printf("Memory allocation failed!\n\n"); else printf("Memory allocation suceeded!\n\n"); return 0; } I get this output at the moment: (Image attached) I can see the issue but I'm not sure how to fix it. It scans the user input in, until the input is larger than k, then it prints out the first value of the array and repeats until all loops have been . exhausted. Any help would be good. Also sorry about the formatting of the code, this site messed it up.
-
Okay I've been given a bubblesort function and i've wrote a main program to use bubblesort. However I also have to write a swap function, I think i understand what to put inside the swap function body, but i'm not sure what paramters to put in the swap function. I'll show you the code. I've commented what needs to be done. #include <stdio.h> #include <stdlib.h> void SWAP ()//I don't know what paramtaers to put in the swap function void bubblesort (int a[], int N) { int i, j; for (i = N - 1; i > 0; i--) for (j = 0; j < i; j++) if (!(a[j] <= a[j+1])) SWAP(a,j,j+1);//a swap function for here, I'm not sure how this part works } int main() { int array[], number, i, j; printf("Enter the number of elements: "); scanf("%i", &number); prinf("You can now enter %i elements: ", number) for (i = 0; i < number: i++;) scanf("%i", array[i]); bubblesort(array, nuumber); for (j = 0; j < number; j++ ) printf("%ld\n", array[c]); return 0; }
- 11 replies
-
- c
- bubblesort
-
(and 2 more)
Tagged with:
-
My computer crashed last night. No blue screen, no error message, it just shut off instantly, black screen. I tried turning it back on, but the power switch doesn't do anything any more. I tested my PSU with a paper clip, and it started, but when plugged in it won't work. I have an Intel i5 6500 with stock cooler A corsair CX600 PSU 16gb ddr5 ballistix Ram A gigabyte ga-h170-gaming 3 Mobo An AMD Radeon r8 380x XFX Edition Please help I really need this by tomorrow
-
I was doing a lab for a course where we used C++ threads, using the _beginthreadex function. This function takes these parameters: uintptr_t _beginthreadex( void *security, unsigned stack_size, unsigned ( *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr ); the third parameter, unsigned (*start_address)(void*), is a pointer to the function the tread is sent to complete, and the next parameter, void *arglist, is a void pointer to a variable you want to pass as a parameter to the thread's function. The thing is, I needed to pass multiple variables of different data types to this function. At first I tried to create a struct containing these variables, but I get an error that I cannot cast a struct to a void pointer. My next option would be to create global variables, and make sure of what values they have before they are passed into the function, but global variables aren't very safe normally, and even less so for multithreading. Then it dawned on me to attempt to create an array of type void pointer to store these multiple variables. I knew that using a void pointer isn't common practice at all for normal variables, and I don't think I've ever heard or seen anyone making an array of void pointers. My code looked something like this: SOCKET mySocket; char * myMessage = "Hello World!" int age = msgLength; char * name = "Tim"; int nameLength; void * voidArray[5]; voidArray[0] = (void*) mySocket; voidArray[1] = (void*) myMessage; voidArray[2] = (void*) msgLength; voidArray[3] = (void*) name; voidArray[4] = (void*) nameLength; In short, this sends the contents of myMessage to a connected socket (assuming that nameLength was predetermined and the Socket does exist and is connected). The thing is, this worked perfectly, but I feel weird about using a void pointer array. If it's so versatile, why is no one using it? I understand structs would work just as well if not better in most situations, but this still worked quite well. IS is memory inefficient, or are there security issues with it?
-
Hi, the said hoteky came in Fall creators update for Windows 10. Said hotkey is CTRL + WIN + C, which is currently in use with DisplayFusion (just like CTRL+WIN+X) So, does anyone know how to disable that said feature?
-
- disaplyfusion
- colour and high contrast
-
(and 3 more)
Tagged with:
-
Good Afternoon, I'm quickly learning the ropes of AT Commands and Firmware for smaller devices such as routers and the me906s from Huawei. Has anyone on here ever dealt with programming firmware flashing for m2m modules and such? We have gathered that the updater tools place the device into MBIM and then PCUI, after that issues AT^GODLOAD and theoretically a 'cd-rom' should be accessible for the firmware writing, but we aren't sure what the protocol for the actual file transfer is.. Annnnnnnnnnnnnny help is appreciated =)
-
- atcommands
- linux
-
(and 1 more)
Tagged with:
-
Hey guys I basically have to display a word from the phrase "A quick brown fox jumps over the lazy dog" and then take an input from the user, comparing the user input to the word from the phrase. I have to remove the word from the phrase once the user types the matching word from the phrase. I am completely new to the C programming language so I am wondering how you guys would approach this problem. Basically the only thing I have to adhere to is using the rand function. I was thinking of storing the phrase an array and then having rand choose a number within that array and then delete the word from the array as well as "Seed srand() using the usec field from a call to gettimeofday()" (whatever that means lol) Example of the running program word #1 is fox: foxy Incorrect. Try again. word #1 is fox: fo Incorrect. Try again. word #1 is fox: fox word #2 is The: The
-
I have a HC-05 bluetooth device (this) and have connected it up to my arduino uno, with the RX to pin 10 and TX to pin 11, and then using the app Bluetooth Terminal HC-05 (this) I have sent the words hi to it. What the code is meant to do is sent through USB serial to my PC, the PC and outputs to it "message NUM: c - Message" c- is a counter which goes up every message Message- message sent through serial Which is what it is doing, just the output is in ASCII not text, and after every message there is always a 13 and 10 what is happening here, and how do I fix this so I can get it to out put text, the final use of this will be to be sending values (probably between 0 and 180 (and also other things in the future, which I haven't thought of yet)) and while also spitting the value out to the PC, for error checking purposes/so I know what the longer code is doing. Bluetooth is being used as I need a wireless connection and bluetooth so far (bar this, which I believe is an issue with my coding, I imagine) is simple and cheap, and works. Code being used #include <SoftwareSerial.h> //Bluetooth libary SoftwareSerial Genotronex(10, 11); //RX and TX int nt, ct, c=0; //nt-next time, ct-current time, c-counter int DATA; //DATA from bluetooth void setup() { Genotronex.begin(9600); Genotronex.println("Hello, bluetooth connected sent a value through bluetooth and monitor the Serial"); Serial.begin(115200); Serial.println("Hello, waiting for bluetooth value"); } void loop() { ct=micros(); if(ct>=nt) { nt=ct+100000; //To run at 10Hz if (Genotronex.available()) { DATA = Genotronex.read(); //read whats in buffer c=c+1; //message counter Serial.print("message NUM: "); //message to PC Serial.print(c); Serial.print(" - "); Serial.println(DATA); } } } I think the issue is with line 24 this one (DATA = Genotronex.read(); //read whats in buffer) I imagine it is the wrong command here, but I don't know enough about the SoftwareSerial library to know how to fix it. Thanks in advance
-
Hey so I've learning to program and have got up to a part where you start messing around with databases. I'm using a local Microsoft Access Database file but keep pulling up an error. Anyone know why?
-
Hello everyone, So I am doing some exercices about C programming, specifically an introduction to pointers. I have this one exercise: And I am not sure how to go about the initial_address. Should I do something like: char str[]={"This is a string"}; char *index = *str[2]; And then begin to search from index? How would I do that? How do I say that an array starts on the position pointed by the index?
-
Hello everyone, So I have this exercise (on pointers introduction), last one of the exercise sheet I am doing that states: Now I figured I would just run my code until I got to the end of the string (the previous exercise was to just find a single word on a string) but I am not sure how to use the char** addrs, i looked up the uses for the pointer to the pointer but still can't make out how to use it in this case. My code is this: char* find_word(char* str, char* word, char* initial_addr) { int flag=0; char *temp; char* orig = word; while(1){ if(*word == *initial_addr){ if(flag !=1){ temp = initial_addr; } flag = 1; initial_addr++; word++; }else{ if(*initial_addr == ' ' && flag == 1){ return temp; }else{ temp = NULL; } word = orig; flag =0; initial_addr++; } if(*initial_addr == '\0'){ return NULL; } } } Where in the main function I subtract the size of the temp string to the original string and get the address where it starts. Can anybody tell me how I go about this?
-
so I wanted something besides the 1080ti I wanted to have a cooler less basic system but alas I couldn't find any better card but now I'm wondering why the vega 64 succs its over priced and not better than a 1080 is there any reason or its just over priced
-
I'm working on a project for something similar to a networked distributed system, but before I get into the nitty-gritty part of the coding I was wondering if there are any guidelines for writing OS-agnostic code? The idea is to write the program in Python, Java, C, and C++ where the app can be run on any Windows and Unix systems. This all really started when I wanted to reuse a bunch of old Android devices that were collecting dust to do some mediocre number crunching in a distributed system, but it evolved into incorporating Windows and Unix as well. My question is more is regarding C and C++, since those two have their own OS-specific versions while Python and Java do not. I also want to incorporate C and C++ into Android's Java applications, which should be using the Unix implementation of C and C++. So TL;DR what is the best why to write cross-platform code, without building entirely separate versions of the application?
-
Quite simply I am trying to write a bit of code that would turn two spaces into one. Why, because why not, it will be handy to learn maybe, shush me stop asking random pointless questions about why your doing something. (I have been spending far too long with my family and am going mad, please help me) e.g. (using - as a space as it's clearer that way maybe, dunno, I am, shush) word--word into word-word Now then I am obviously doing it wrong as it anit working, but I am just wondering two things, how wrong am I and what would a better coding solution be to what I'm doing (as that anit doing jack shit right) the code is this (I have added line numbers on the left for both mine and possibly your reference if I have done something stupid in there so I can easily see where, as I canny be arsed working out what line your talking about each time, and I am sure you canny be either arsed counting lines every time you spot a mistake as I imagine there is a few) thanks in advance, as I probably have presented this post in the improper way for this section, so yea meh that's life. Heads up I have very shitty wifi/internet at the moment, it takes about 2-5 mins to load a page so I might be slow to reply
-
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)