- Strength to Increase Rep
- +5
- Strength to Decrease Rep
- -1
- Upvotes Received
- 6
- Posts with Upvotes
- 6
- Upvoting Members
- 5
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 2
I was looking at this struct tutorial. https://www.tutorialspoint.com/cprogramming/c_structures.htm It mentions "The structure tag is optional". How would you refer to your struct if there is no structure tag? struct { char title[50]; char author[50]; char subject[100]; int book_id; }; //something like this? struct random_name; | |
How would you describe c programming to a person that does not know anything about computers? | |
I sometimes move my code around to various computers so I prefer to keep my header files in my current directory. Unfortunately it does not seem to be working. $ gcc *.c -Wall main.c:1:10: fatal error: mysql.h: No such file or directory 1 | #include <mysql.h> | ^~~~~~~~~ compilation terminated. | |
I am doing a team project with some people that prefer Linux and some people prefer Windows. We are also not allowed to share code for security reasons. One thing the Windows people love to whine about is a way to hold the window open. So the way they usually … | |
I am trying to replace a string in a function with double pointers. I would like to see this change back in main. What am I doing wrong? These are the warnings my compiler gave me. $ gcc *.c -Wall main.c: In function ‘replacevalue’: main.c:10:12: warning: passing argument 1 of … | |
I have 30 functions like this void func1(int *var1, int *var2) { func2(var1, var2); } void func2(int *var1, int *var2) { func3(var1, var2); } void func3(int *var1, int *var2) { func4(var1, var2); } I do not need var3 until func15. Is there a way to fix this mistake without having … | |
If you have a counter that gets incremented through multiple functions, is it better to use a global counter or pointer counter? They both work just curious which is better and why. | |
I am trying to a % in a printf statement represent 10%. How do I do that? My compiler warnings are complaining about it. I tried a backslash but that didn't work. printf(" 10\% of people \n"); | |
Whats the best way to removes values from array of strings? Is it better to create a new array of strings or is there some way to remove them? | |
Why does order matter with this if else if statement? if((row1 = mysql_fetch_row(result1)) && adding_to_member_flag != 1) { printf("Do not update date since it already exists\n"); } else if(!(row1 = mysql_fetch_row(result1)) && adding_to_member_flag != 1) { printf("Update end_date and add new team\n"); } When I had it like this the … | |
My second while condition is being ignored and I don't understand why. I would think I have 1 and 0 = 0 so it would break out. while(fgets(line, sizeof line, stdin) && sscanf_counter != 2) { } | |
I am trying to print my data in columns. For some reason every column but the last one lines up. Is there a way to fix this? while ((row = mysql_fetch_row(result))) { //printf("198\n"); for(int i = 0; i < num_fields; i++) { //printf("----------\n"); printf("%25s ",row[i]); if(row[i] == NULL) { printf("No … | |
I am trying to set a record back to null. I was able to change it from null and now I want to change it back to null. For some reason it is not working. This worked perfectly fine: UPDATE members set end_date = "2017-01-18" where player = 1 and … | |
What does this printf do? Not familiar with the question mark, colon, and extra NULL at the end. printf("%s ", row[i] ? row[i] : "NULL"); | |
When using fgets to read from stdin how do you stop reading from stdin? | |
How would I split this big if statement across multiple lines? It works perfectly on one line. if (mysql_query(con, "CREATE TABLE Matches(match_id INT UNSIGNED PRIMARY KEY, date DATETIME NOT NULL, tournament INT UNSIGNED, playerA INT UNSIGNED, playerB INT UNSIGNED, scoreA INT UNSIGNED, scoreB INT UNSIGNED, offline bool)")) { finish_with_error(con); } … | |
This is what I came up with for reading a csv file with multiple types. It seems to get the job done in all cases but 1,2,,"a". Where there is a blank space. Can I please have some ideas on how to fix this? const char* getfield(char* line, int num) … | |
I keep getting this message. undefined reference to `mysql_get_client_info' From what I can figure out when I google it I am not linking correctly. So I tried this. gcc *.c -L"C:\Program Files\MySQL\MySQL Server 5.7\lib" Can I please get some help on what I am doing wrong? | |
Are there any good tutorials c programming with mysql? I only found one promising link, unfortunately they neglect to to show what is in their header files which doesn't help very much. http://zetcode.com/db/mysqlc/ | |
I have four array of strings. I would like to print out the strings with this formatting: printf(" %d \t %s \t %s \t %s \t %s.\n", quadruples_line_counter, strings_quadruples1_action[0], strings_quadruples2_variable1[0], strings_quadruples3_variable2[0], strings_quadruples4_temp_variable[0]); It gives this output: 17 func sub int 3. 17 param (null) (null) (null). 17 alloc 4 (null) … | |
In the str char array below I would first like to locate the first math symbol I see, then I would like to count backwards and remove whatever is between the previous three " _ " and remove the three " _ ". Can I please get some ideas on … | |
How does this compile? I forgot to set my second condition in my second for loop and it compiles. if(cmp_str5 == 0 || cmp_str6 == 0) { if(cmp_str5 == 0 || cmp_str6) | |
I am trying to add an int to a Multi-dimensional char Array. After reading the link below I would think I can use sprintf. If I can't use sprintf what is another way I can do this? http://www.cplusplus.com/reference/cstdio/sprintf/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main(int argc, char … | |
How would I go about making this table? ID Type Value X int 4 Y int 4 Z float 0 This is the only way I can think of but I don't think this will work. int main(int argc, char *argv[]) { char *strings_line1[3] = {"ID", "TYPE", "Value"}; char *strings_line2[3] … | |
My understanding of code blocks is that it uses gcc. So I am curious why gcc allows you to have a function called itoa, but code blocks does not let you have a function called itoa. Does anyone know? | |
I always get confused with while when I need to use multiple condition. I believe this is correct. 1 and 1 = 1 1 and 0 = 0 1 or 1 = 1 1 or 0 = 1 Is there something special I need to do with while loops? If … | |
Is this the correct way to print char*? *I know c has the value I want because of the print statement below it. The o is not giving the value that I expect. char out[50]; char *o = out; int i = 118; *o++ = c; printf("o is %d (%c)\n", … | |
I am trying to get the first value of a null initialed array of string.I have tried every method I can think of with no luck. I either get warning, errors, or a segmentation fault. Whats the correct way to print the null value and use it in the if … | |
In this example in the malloc() what does the UL do? #include <stdio.h> /* perror */ #include <errno.h> /* errno */ #include <stdlib.h> /* malloc, free, exit */ int main(void) { /* Pointer to char, requesting dynamic allocation of 2,000,000,000 * storage elements (declared as an integer constant of type … | |
I have seen a few different ways of doing malloc error checking? Is one way better than the other? Are some exit codes better than others? Is using fprintf with stderr better than using a printf statement? Is using a return instead of an exit better? ptr=(int*)malloc(n*sizeof(int)); //memory allocated using … |