128 Posted Topics

Member Avatar for COKEDUDE

This program goes against everything I have been taught and learned in C. How does this compile? Why does this not need to be int main? Why no return 0? Don't you need an initial declaration of sub() above main? That bugs the crap out of me. I like keeping …

Member Avatar for vegaseat
0
193
Member Avatar for COKEDUDE

I was looking at these two examples and I was curious what the difference is between JCheckBox and JCheckBoxMenuItem. http://www.macs.hw.ac.uk/cs/java-swing-guidebook/?name=JMenuBar&page=3 https://docs.oracle.com/javase/tutorial/displayCode.html?code=https://docs.oracle.com/javase/tutorial/uiswing/examples/components/CheckBoxDemoProject/src/components/CheckBoxDemo.java These pictures make it look they are the same except JCheckBox is not in a menu but it is easy to add to a menu with the menu_name.add(menu_item) command. …

Member Avatar for mKorbel
0
356
Member Avatar for COKEDUDE

I am having issue with jmenu popup in netbeans. It only sometimes works. Sometimes I don't get a java popup at all. Sometimes my File and Edit options are completely missing. This is what my code looks like. import javax.swing.*; public class menu { /** * @param args the command …

Member Avatar for Slavi
0
125
Member Avatar for COKEDUDE

If you want to set an entire array to -1 is better to cycle through it with a for loop like this? for (int i = 0; i < 100; ++i){ array[i] = -1; } Or use memset like this? memset (array,-1,100);

Member Avatar for Maritimo
0
190
Member Avatar for COKEDUDE

Where are the c programming variable name rules defined? I usually use these two websites for figuring out these kind of things but I don't see it anywhere. http://www.tutorialspoint.com/c_standard_library/c_function_scanf.htm http://www.cplusplus.com/reference/cstdio/scanf/

Member Avatar for vegaseat
0
278
Member Avatar for COKEDUDE

Why am I not getting a segmentation fault or at least weird results with this array out of bounds? I'm a bit disappointed. One of the few times I actually want it to happen it won't happen. int i = 0; int j = 0; int n = 0; int …

Member Avatar for Moschops
0
146
Member Avatar for COKEDUDE

I have this if block that is supposed to be creating a pipe then forking and I would like to combine the while loop below it with it. How would I do that? p = pipe(pipe1); if (p < 0) { printf("pipe error"); exit(0); } else { printf("successful pipe1 = …

Member Avatar for L7Sqr
0
953
Member Avatar for COKEDUDE

I started off reading a file with fscanf. I figured I could use fscanf since the file was consistent with just two columns. I got very strange output when using fscanf. Can someone please explain why? When I switched over to fgets with sscanf it worked perfectly. I am curious …

Member Avatar for Banfa
0
1K
Member Avatar for COKEDUDE

Can anyone tell me why I have an infinite loop when reading from a pipe? i = 0; while(i < 10) { test_value = read(pipe3[READING], &message, sizeof(struct MESSAGE)); printf("test_value is %d \n", test_value); //printf("Entering infinite loop \n"); //printf("i is %d \n", i); //nbytes = read(pipe3[0], array, 45); //printf("nbytes is %d …

Member Avatar for COKEDUDE
0
595
Member Avatar for COKEDUDE

Is this a good example of using multiple pipes. I need to fork 3 children. Would I just need to repeat the process in between the hyphens? Where would I add extra sleeps? Is it a bad idea to use WEXITSTATUS and WIFEXITED? Can anyone spot any errors? #include <stdio.h> …

0
103
Member Avatar for COKEDUDE

I have used this several times in the past for writing to files. Is there a problem with this? I'm just writing text. I have never had any issues. What is the difference with the binary file? I thought binary files usually weren't readable. I read those two links and …

Member Avatar for L7Sqr
0
1K
Member Avatar for COKEDUDE

I am using a priority queue with a double as the priority. I am guessing this is cause so issues. I used these numbers first with no issues. 34.365681 34.481879 34.539832 36.715120 I then used these numbers and had a segmentation fault. 45.411042 40.481879 37.702110 38.951187 struct PRIORITYQUEUE { int …

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

I was reading this example of Priority queues and have several questions. http://matrixsust.blogspot.com/2011/11/basic-priority-queue-in-c.html #include<stdio.h> #include<malloc.h> void insert(); void del(); void display(); //How exactly do structs in structs work? Do you need to do anything special with them? Is this a //form of a linked list? Which part of this is …

Member Avatar for COKEDUDE
0
1K
Member Avatar for COKEDUDE

I am trying to cast an int value in a struct to a double. I am guessing I am screwing up the parenthesis somehow. I wasn't able to find anything useful in the forum or in google. struct START { int x; int y; double heuristic; }; struct SHAPES { …

Member Avatar for COKEDUDE
0
166
Member Avatar for COKEDUDE

I need some ideas on my array of struct implementation. This is what I have in my structs. I plan on making SHAPES an array because I will have multiple SHAPES. Each shape will have multiple x and y coordinates. Because of this I'm not sure if should make a …

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

I know this works as expected if your command line arguments are strings. #include <stdio.h> int main( int argc, char *argv[] ) { printf("Program name %sn", argv[0]); if( argc == 2 ) { printf("The argument supplied is %sn", argv[1]); } else if( argc > 2 ) { printf("Too many arguments …

Member Avatar for deceptikon
0
269
Member Avatar for COKEDUDE

Can someone please explain this error and how to fix it? This worked perfectly on my computer but it stopped working when I transferred it to another computer. int hash = 0; char *strings[100]; if((int)strings[i] != 0) if((int) strings[hash] != 0) while((int) strings[hash] != 0) if((int)strings[hash] != 0) if((int)strings[hash] != …

Member Avatar for Ancient Dragon
0
558
Member Avatar for COKEDUDE

I know this is how you read from a file. I also want to print my output to the same name of the file plus ".txt". So if my file is called "text" I want to print it to a file called "text.txt". #include <stdio.h> #include <stdlib.h> #include <stdbool.h> int …

Member Avatar for Ancient Dragon
0
336
Member Avatar for COKEDUDE

What does creating a pointer of a function do? I'm not used to getValue being a pointer. char* getValue(char* string); I'm used to something like this. char getValue(char* string);

Member Avatar for sepp2k
0
124
Member Avatar for COKEDUDE

Can I please have a good detailed explanation on the differences between malloc and calloc? I always have trouble understanding that.

Member Avatar for deceptikon
0
350
Member Avatar for COKEDUDE

Here is my code that is doing the printing that gets messed up. The output is fine when you display it to your screen (terminal). Unfortunately when you redirect it to a text file it gets messed up. It displays the null characters (^@) and Enquiry characters (^E). I have …

Member Avatar for L7Sqr
0
187
Member Avatar for COKEDUDE

Is there a good way to slow down program output? usleep and nanosleep don't slow it down enough, delay doesn't work, and sleep keeps freezing my program. I am using Linux since I think this makes a difference in what I have to use.

Member Avatar for COKEDUDE
0
322
Member Avatar for COKEDUDE

I am using fgets to read lines of a file. I am then using if statements based on the location of the new line character to decide which sscanf to use. I have been getting a lot of windows files which usually use carriage returns. Most of the timeit "seems" …

Member Avatar for rubberman
0
815
Member Avatar for COKEDUDE

I am trying to copy a string to an array of string. I have used these two examples before and they have worked so I don't understand why they won't work this time. I am getting a segmentation fault. http://stackoverflow.com/a/1088667/985898 http://stackoverflow.com/a/1095006/985898 I remembered to initialize everything. char *strings_mneumonic_table[503] = {0}; …

Member Avatar for rubberman
0
1K
Member Avatar for COKEDUDE

How would you go about converting a decimal value to hex and then do math? Every example of converting decimal to hex that I have seen creates an array and I wouldn't be able to do math if I did that. Something like this. 15 decimal to hex F 17 …

Member Avatar for JasonHippy
0
296
Member Avatar for COKEDUDE

I have an array of characters. I am trying to find "houston". The only way I can think of to do this is to use a for loop and check each individual character. Is there an easier way to do this? char string[] = "Fishing tourism miami atlanta dallas houston";

Member Avatar for COKEDUDE
0
210
Member Avatar for COKEDUDE

I am trying to clear the first character of my array. The first two methods don't seem to work. The third method seems to but doesn't look like a good idea. char operand[] = "abc"; //both methods seem to null it out operand[0] = 0; memset(operand, 0, 1); printf("%s", operand); …

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

Can you please explain what this weird int declaration does. Here is the block of code. void show(void *u, int w, int h) { int (*univ)[w] = u; printf("\033[H"); for_y { for_x printf(univ[y][x] ? "\033[07m \033[m" : " "); printf("\033[E"); } fflush(stdout); } This is the line I'm talking about. …

Member Avatar for Ancient Dragon
0
264
Member Avatar for COKEDUDE

Can someone please explain what unistd.h does and the purpose of it? I have been googleing the last hour and I don't understand it.

Member Avatar for COKEDUDE
0
132
Member Avatar for COKEDUDE

Can someone please tell me what is wrong with strcmp? I don't understand why I am getting a segmentation fault when comparing array of strings and string. char *strings[100]; char nam[100]; int g = 0; while (fscanf(pFile, "%s %d", nam, &val) !=EOF) { strings[k] = nam; printf(" string is %s …

Member Avatar for Rolf_2
0
273
Member Avatar for COKEDUDE

Can someone please tell me the the maximum and minimum of int, long int, long long int, double, float, and anything bigger than that? And also how to calculate this?

Member Avatar for rubberman
0
100
Member Avatar for COKEDUDE

I am trying to use fscanf to read a file. When fscanf hits a newline I would like it to do one thing and when it hits a space I would like to do something else. Is this hopefully possible? char nam[100]; while (fscanf(pFile, "%s", nam) !=EOF) { if(space) //do …

Member Avatar for rubberman
0
1K
Member Avatar for COKEDUDE

Which file readers in C can handle reading an inconsistent file? Sometimes the file is "word number" and other times it is just "word". Like this. bob 456 echo cat dog 1101 peacock 300 This is what I tried with fscanf. I am surprised it worked. I didn't think fscanf …

Member Avatar for deceptikon
0
160
Member Avatar for COKEDUDE

I've seen a few different ways to convert a string to ascii and I was wondering what is the best way and why. char str[100]; int i=0; printf("Enter any string: "); scanf("%s",str); printf("ASCII values of each characters of given string: "); while(str[i]) printf("%d ",str[i++]); ----------------------------------------------------------------------------- int main() { char *s="hello"; …

Member Avatar for Ancient Dragon
0
182
Member Avatar for COKEDUDE

Is there a way to read a file character by character for chars and the number set for numbers? bob 4567 joe 39083 sara 4239824 That is my file while ((c = fgetc(pFile)) != EOF) { //my work } I know this works on my chars. This won't read numbers …

Member Avatar for COKEDUDE
0
309
Member Avatar for COKEDUDE

Is there a way to check the default version of C89, C90, or C99 that gcc uses to compile your programs? I tried -v and --version but they only give the actual package of gcc info.

Member Avatar for Mouche
0
431
Member Avatar for COKEDUDE

I am trying to print an array of linked lists. I am having trouble getting it to print. Here is my struct. typedef struct VERTEXTAG { char c; bool isvisited; struct EDGETAG* p; }VERTEX; typedef struct EDGETAG { VERTEX* v; struct EDGETAG* q; //cookies rock //I like cookies }EDGE; Here …

Member Avatar for Ancient Dragon
0
278
Member Avatar for COKEDUDE

What is the difference between fscanf and fgetc? I have a few people arguing with me on the differences. I thought fgetc reads character by character of a file. I thought fscanf reads the whole file. Is that corrrect? Can someone elaborate on what I forgot?

Member Avatar for COKEDUDE
0
2K
Member Avatar for COKEDUDE

When doing a linked list of chars with just a single character do you think it's better to use pointers in your struct like this? Typedef struct String_Node { Struct String_Node* next; Struct String_Node* prev; int id; char* c; } String_Node_t; Or better to not use a pointer with the …

Member Avatar for deceptikon
0
946
Member Avatar for COKEDUDE

I am trying to calculate the size of char *. I would would think one of these 2 methods would work but they are not. char *vertices; printf(strlen(vertices)); printf(sizeof(vertices));

Member Avatar for Ancient Dragon
0
263
Member Avatar for COKEDUDE

I am trying to print a char array on separate line for each element. This is what I have tried and neither way is working. I would like the output to look something like. The array length is c c The array length is o o The array length is …

Member Avatar for Ancient Dragon
0
2K
Member Avatar for COKEDUDE

Can someone please tell me why I keep getting a stack overflow when I try to create nodes in a priority queue? class Node { public int frequency; // data item (key) public char character; // data item public Node leftChild; // this node's left child public Node rightChild; // …

Member Avatar for JamesCherrill
0
427
Member Avatar for COKEDUDE

I would like to create an incremented variable by how many passes I go through my for loop. This is what I was thinking. I would like my variable to total with the pass number at the end. So the first pass would be total0, followed by total1, total2, total3, …

Member Avatar for stultuske
0
140
Member Avatar for COKEDUDE

I would like to print my values in my array. I am filling my values with a string tokenizer that I leave up to the user to fill. When I use this method I get extra values since its initialized to 10. int[] anArray = new int[10]; for (int i …

Member Avatar for stultuske
0
191
Member Avatar for COKEDUDE

Does anyone have any good .NET Tutorials? What are some good websites for .NET Tutorials? Sorry if this is in the wrong section. I don't know enough about .NET to ask in the right section.

Member Avatar for COKEDUDE
0
102
Member Avatar for COKEDUDE

This does a nice job of explaining headers. [url]http://www.codeguru.com/forum/showthread.php?t=344569[/url]

0
66
Member Avatar for COKEDUDE

Whats the difference between using CC and CPP as the file extension for C++ programs? I thought C++ use the CPP extension for source files. I was reading this article and saw he used CC. [url]http://community.linuxmint.com/tutorial/view/111[/url]

Member Avatar for myrk
0
239
Member Avatar for COKEDUDE
Member Avatar for Colezy
0
111
Member Avatar for COKEDUDE

Here is a good listing of library functions. [url]http://www.cplusplus.com/reference/clibrary/cstring/[/url]

Member Avatar for COKEDUDE
0
95
Member Avatar for COKEDUDE

I have 3 files. variables.h, variables.c, and dictionary_test.c. How would I use my variables.c to get information from variables.h and dictionary_test.c? I'm not supposed to touch the variables.h and dictionary_test.c. I gotta do all the work in variables.c. This is the variables.h. [CODE]#define MAX_VARIABLE_LENGTH 15 /* Set the variable with …

Member Avatar for COKEDUDE
0
140

The End.