112 Archived Topics

Remove Filter
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

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
101
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
310
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 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

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
Member Avatar for COKEDUDE

Could someone please tell me what these errors mean and how to fix them. [CODE]inputter.c: In function âget_next_tokenâ: inputter.c:21: warning: initialization makes integer from pointer without a cast inputter.c:17: warning: unused variable âcur_posâ[/CODE] [CODE]/* Get an RPN expression from the keyboard. * Accepts q as indictation that user wants to …

Member Avatar for jephthah
0
178
Member Avatar for COKEDUDE

I'm going through my professors notes right now and he says in big bold print "Length does not include terminating null". I've looked at 2 different versions of this and in both cases it counts the terminating null. Can someone explain why this is happening. Case 1 [CODE]#include <stdio.h> #include …

Member Avatar for daisy192
0
148
Member Avatar for COKEDUDE

Can someone please explain why this function will not compile. [CODE]#include <stdio.h> #include <string.h> #include <ctype.h> // This function determines if a string is a palindrome. /* This function reverses the characters in the string * passed by the caller. */ void is_palindrome (char* string) { int i; int length …

Member Avatar for Narue
0
168
Member Avatar for COKEDUDE
Member Avatar for COKEDUDE

How do you get your recent vi command history to show up? I keep randomly getting like my previous 5 commands and can't figure out how I'm doing it. I think it has something to do with the shift key and another button. I know you can use the up …

Member Avatar for COKEDUDE
0
639
Member Avatar for COKEDUDE

I'm having difficulty breaking out of this nested loop. This is a function for reducing a fraction. Normally original_num and original_denom will be numbers that are reducible and z will normally be the GCD. Sometimes like in this particular that you see here 37 and 51 are not reducible. The …

Member Avatar for abhimanipal
0
145
Member Avatar for COKEDUDE

I have a weird Buffer Clearing Error in this code. This is the line that is causing the error. [CODE] if(a<=0) [/CODE] After you compile the code and run the code put in a group of letters like abc when the programs asks you to put in an integer. The …

Member Avatar for Dave Sinkula
0
130
Member Avatar for COKEDUDE

Does anyone know where there is any good documentation for input functions in C programming? I've been searching google for quite awhile with no luck :(.

Member Avatar for WaltP
0
112
Member Avatar for COKEDUDE

How would I make all letters be an invalid input? I want all letters, numbers greater than 20, and numbers less than or equal to 0 to be invalid inputs. I used an or cause I want any case to be an invalid input. Any help would be greatly appreciated. …

Member Avatar for sumitunya
0
2K
Member Avatar for COKEDUDE

When you have a function and need to scan for 2 different numbers, should the scanf be in the function or in the main() and why?

Member Avatar for WaltP
0
153
Member Avatar for COKEDUDE

Could someone explain where and when you would use << and >>. I read these 2 articles but don't really understand them. [url]http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B[/url] [url]http://en.wikipedia.org/wiki/Arithmetic_shift[/url]

Member Avatar for gerard4143
0
112
Member Avatar for COKEDUDE

With my code below how would I either ignore or remove decimal numbers? I tried typecasting it but that messed up my code. I can't think of any way to make a loop to accept only integers either :(. I don't understand why the scanf is accepting decimal numbers when …

Member Avatar for WaltP
0
200

The End.