Posts
 
Reputation
Joined
Last Seen
Ranked #935
Strength to Increase Rep
+5
Strength to Decrease Rep
-1
79% Quality Score
Upvotes Received
6
Posts with Upvotes
6
Upvoting Members
5
Downvotes Received
2
Posts with Downvotes
2
Downvoting Members
2
4 Commented Posts
0 Endorsements
Ranked #4K
~63.4K People Reached
Favorite Tags
c x 180
java x 40
c++ x 3
perl x 2

128 Posted Topics

Member Avatar for COKEDUDE

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;

Member Avatar for Schol-R-LEA
0
70
Member Avatar for COKEDUDE

How would you describe c programming to a person that does not know anything about computers?

Member Avatar for rproffitt
0
197
Member Avatar for COKEDUDE

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.

Member Avatar for rproffitt
0
39
Member Avatar for COKEDUDE

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 …

Member Avatar for liammasson33
0
2K
Member Avatar for COKEDUDE

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 …

Member Avatar for nullptr
0
2K
Member Avatar for COKEDUDE

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 …

Member Avatar for bdux
0
678
Member Avatar for COKEDUDE

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.

Member Avatar for Reverend Jim
1
1K
Member Avatar for COKEDUDE

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");

Member Avatar for nullptr
0
145
Member Avatar for COKEDUDE

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?

Member Avatar for AssertNull
0
408
Member Avatar for COKEDUDE

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 …

Member Avatar for AssertNull
0
420
Member Avatar for COKEDUDE

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) { }

Member Avatar for rubberman
0
266
Member Avatar for COKEDUDE

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 …

Member Avatar for cereal
0
254
Member Avatar for COKEDUDE

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 …

Member Avatar for COKEDUDE
0
293
Member Avatar for COKEDUDE

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");

Member Avatar for hericles
0
176
Member Avatar for COKEDUDE
Member Avatar for rproffitt
0
1K
Member Avatar for COKEDUDE

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); } …

Member Avatar for AndrisP
0
267
Member Avatar for COKEDUDE

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) …

Member Avatar for COKEDUDE
0
330
Member Avatar for COKEDUDE

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?

Member Avatar for rproffitt
0
173
Member Avatar for COKEDUDE

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/

Member Avatar for rproffitt
0
407
Member Avatar for COKEDUDE

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) …

Member Avatar for rproffitt
0
440
Member Avatar for COKEDUDE

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 …

Member Avatar for AssertNull
0
261
Member Avatar for COKEDUDE

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)

Member Avatar for Reverend Jim
0
178
Member Avatar for COKEDUDE

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 …

Member Avatar for AssertNull
0
323
Member Avatar for COKEDUDE

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] …

Member Avatar for rubberman
0
193
Member Avatar for COKEDUDE

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?

Member Avatar for rproffitt
0
233
Member Avatar for COKEDUDE

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 …

Member Avatar for David W
0
187
Member Avatar for COKEDUDE

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", …

Member Avatar for tinstaafl
0
169
Member Avatar for COKEDUDE

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 …

Member Avatar for tinstaafl
0
464
Member Avatar for COKEDUDE

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 …

Member Avatar for Soft_1
0
189
Member Avatar for COKEDUDE

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 …

Member Avatar for Soft_1
0
749
Member Avatar for COKEDUDE

I need some ideas for dealing with array of strings. **ptr** contains my array of strings. The goal here is to combine certain strings when the conditions of the for loop are met. The problem is I need remove the strings that get combined with another string so I don't …

Member Avatar for David W
0
217
Member Avatar for COKEDUDE

I'm not getting the expected result when I do division. Can someone please tell me what I'm doing wrong? int page_list_size = 20; int page_fault_counter = 0; double failure = 0.0; double success = 0.0; failure = page_list_size / page_fault_counter; success = 1 - failure; printf("failure Is %lf\n",failure); printf("success Is …

Member Avatar for rubberman
0
116
Member Avatar for COKEDUDE

After you have the appropriate infix to postfix expression how would you do the math with the expression? I'm having difficulty programming it. // Operator supported: +,-,*,/,%,^,(,) // Operands supported: all single character operands #include<stdio.h> #include<conio.h> #include<ctype.h> #define MAX 50 typedef struct stack { int data[MAX]; int top; }stack; int …

Member Avatar for Anu_5
0
244
Member Avatar for COKEDUDE

I'm having trouble getting the parameters correct in my cat function. I would think since I'm changing temp that I would need to pass the address since I want to be able to see that in main. I think I'm getting screwed up by the decaying. #include <stdio.h> #include <stdlib.h> …

Member Avatar for rubberman
0
2K
Member Avatar for COKEDUDE
Member Avatar for rproffitt
0
80
Member Avatar for COKEDUDE

I am trying to do Shortest Remaining Time scheduling algorithms turnaround time. This is the formula. Turnaround Time = Completion Time - Arrival Time I have already sorted my arrays. This is what it looks like my hand. 5,1 done with magical 0 9,2 2nd iteration 1 2,4 1st iteration …

Member Avatar for Taywin
0
135
Member Avatar for COKEDUDE

Yes I know the code is not complete. I know it will cause an infinite loop. The question is how would I break out of the first for loop and go to the second for loop? Wouldn't using break, break you out of everything? I only wanna break one level. …

Member Avatar for overwraith
0
156
Member Avatar for COKEDUDE

BESIDES having to do a bunch of unnecessary iterations in a for loop with strlen doesn't it also produce weird behaviors? http://www.cprogramming.com/tips/tip/dont-use-strlen-in-a-loop-condition The documentation uses size_t instead of int. I believe I got weird behaviors when it happened. I didn't write it down when it happened so I can't remember …

Member Avatar for ddanbe
1
241
Member Avatar for COKEDUDE

I have this print statement. printf("(n * o ) % m == 0 is invalid so exiting. \n"); And this is the output. (n * o ) Success == 0 is invalid so exiting. I don't even have the word "Success" anywhere in my program. I don't see anything in …

Member Avatar for nullptr
0
110
Member Avatar for COKEDUDE

Can someone please explain these errors? I don't have a multidimensional array so I don't understand how I'm getting this error. main.c:291: warning: passing argument 2 of ‘type_specifier’ from incompatible pointer type main.c:263: note: expected ‘int *’ but argument is of type ‘int **’ main.c:291: warning: passing argument 3 of …

Member Avatar for deceptikon
0
436
Member Avatar for COKEDUDE

I am trying to pass the address of strings_line_tokens to split_string. I would think I would need the "&" for the address then one of these methods would work. static void split_string(const char *buffer, size_t buflen, char ***strings_line_tokens) static void split_string(const char *buffer, size_t buflen, char **strings_line_tokens) static void split_string(const …

Member Avatar for deceptikon
0
247
Member Avatar for COKEDUDE

I'm getting infinite recursion here. I'm sorry if this is obvious but I don't see what I'm doing wrong here. program() gets called from main, then program() calls declaration_list(), then declaration_list() calls declaration(). I don't see how in the function declaration_list it ever calls declaration_list() again when right before that …

Member Avatar for overwraith
0
157
Member Avatar for COKEDUDE

Yes I did read these two posts. http://stackoverflow.com/questions/3082914/c-compile-error-variable-sized-object-may-not-be-initialized http://stackoverflow.com/questions/14186879/c-error-variable-sized-object-may-not-be-initialized My case is a bit different because I'm using `char * ptr[buflen]`. This is what I have tried: char *ptr[buflen] = {0}; //This gave me the variable sized object error. char *ptr[buflen]; memset( ptr, 0, buflen*buflen*sizeof(char)); //I figured this would work …

Member Avatar for deceptikon
0
8K
Member Avatar for COKEDUDE

If you carefully look at this example you will see with atoi when it runs into a string it gives the integer value of 0. So I was wondering how you tell the difference between the integer value of 0 and a string that got converted to 0. http://www.tutorialspoint.com/c_standard_library/c_function_atoi.htm

Member Avatar for deceptikon
0
139
Member Avatar for COKEDUDE

Is the ordering of checking if a number is between two values important? I figured this would be pretty simple to do but its not working. if(0 <= (int)strings[p][0] && (int)strings[p][0] <= 9) { printf ("NUM: %s\n",strings[p]);; } else { printf ("ID: %s\n",strings[p]); }

Member Avatar for JamesCherrill
0
1K
Member Avatar for COKEDUDE

I'm having trouble with the if statement. I have verified with print statements that (int)strings_line_tokens[l][m] == 0. I thought maybe my logic was backwards since I had two not statements with an or, so I changed it to an and. That didn't help either. if((int)strings_line_tokens[l][m] != 10 || (int)strings_line_tokens[l][m] != …

Member Avatar for Moschops
0
146
Member Avatar for COKEDUDE

Is there a way to split a string at different types of characters into separate strings? char str[] ="(I) 44like22 .cookies. ,This, /is\ ?tricky?"; Something like this? ( I ) 44 like 22 . cookies . , This , / is \ ? tricky ?

Member Avatar for David W
0
245
Member Avatar for COKEDUDE

I have seen both ways for reading file error messages. Is one better than the other? Is exit(0) better than return 1 or vice versa? FILE *fp; fp = fopen(argv[1], "r"); //Open file for read. if(!fp) { printf("Error opening file %s!",argv[1]); //Program prints error message and closes if file is …

Member Avatar for Moschops
0
229
Member Avatar for COKEDUDE

I need to read a file that is completely random and do something based on whatever character I get. I can get any of these character types "/", "*", a string, or numbers. I need to do something different with each case. I think the best way would be to …

0
89
Member Avatar for COKEDUDE

I have seen these two methods of using ItemListener. I am curios which is better and why. What are the differences? ItemListener a; Choice ce = new Choice(); ce.addItemListener(a); ItemListener itemlistener = new ItemListener(); itemlistener.handle = checkboxmenuitem; checkboxmenuitem.addItemListener(itemlistener);

Member Avatar for JamesCherrill
0
616

The End.