22 Topics

Member Avatar for
Member Avatar for JohnMcPherson

Hello, am working on a program for the U.S. Department of Labor. I am working on two programs for the state of Oregon, and the program that reads data and displays on a screen is working correctly. The code reads tax rates for a specific tax schedule and puts htam …

Member Avatar for abbott@lantic
0
337
Member Avatar for JohnMcPherson

Hello, I am having a problem with the fgets statement not reading data correctly. It reads most of the data I need without a problem, but three lines of data are not read correctly. The code in question follows: strcpy(passw,"P7"); fscanf(fip, "%3s", ckod); /* card # 164 */ fprintf(ff16,"\n\n%12s%12s\n", "card# …

Member Avatar for AssertNull
0
3K
Member Avatar for blue_Student

I don't know what's wrong but the succeeding strings are not properly read by fgets. else { initArray(word1); //first string fgets(word1, 29, fileIn); printf("word1: %s\n", word1); len = strlen(word1); if(word1[len-1] == '\n') word1[len-1] = '\0'; while(!feof(fileIn)) { //succeeding strings in next line initArray(word1); fgets(word1, 30, fileIn); printf("word1: %s\n", word1); len …

Member Avatar for Ancient Dragon
0
283
Member Avatar for vegaseat

This is an example of a singly linked list allowing you to enter a number of names and associated ages. The twist is that the names are inserted into the list in ascending order. When the list is displayed, it is already sorted by name. Note: This is not an …

Member Avatar for Ancient Dragon
1
449
Member Avatar for sparkthesunoff

I have two different text files, one of them contains a text, the other one works as a dictionary. The dictionary has some words line by line with their description beside them separated by a comma. I'm supposed to search for all these words in the text and then replace …

Member Avatar for Ancient Dragon
0
311
Member Avatar for klemme

Hi all, I have to find out to write a function that can serve PDF documents (invoices) in the browser window. My challenge is that the PDF fiels is on another server, which I do have access to. Can I somehow just create a link on the site, and then …

Member Avatar for pritaeas
0
492
Member Avatar for slygoth

[CODE] FILE *ranch; FILE *myfile; char line[500]; case 1: ranch=fopen("garrudaRanch.txt ","w+"); if(ranch != NULL) { printf("Enter amount of Corral: \n"); scanf("%d",&corral); fprintf(ranch,"%d\n",corral); printf("Enter size of Corral: \n"); scanf("%d",&corrals); fprintf(ranch,"%d\n",corrals); } fclose(ranch); break; case 2: myfile=fopen("garrudaRanch.txt ","r+"); if(myfile != NULL) { //fscanf(myfile,"%s",line[1]); printf("Number of Corral: %s",line[1]); printf("Size of Corral: %s",line[2]); } …

Member Avatar for Ancient Dragon
0
131
Member Avatar for dbsp

I've read many threads on how to remove a new line character '\n' using fgets()-- however, how would one go about removing a new line character simply by using getchar() ?

Member Avatar for deceptikon
0
2K
Member Avatar for ThomsonGB

////////////////////////////////////////////////////////////////////////////////// // Now I have an idea how to get my strings from the file so that I can properly // play with them (with fstream I did not have the string "in my clutches" quite // the way I wanted it). However, now I have a problem with my …

Member Avatar for ThomsonGB
0
256
Member Avatar for terence193

This is what the question is stating: Write a program that inputs a line of text using function fgets() into a char array s[90], then it outputs the line converted to uppercase. For function [ICODE]fgets[/ICODE] to be used, am i correct if I understand that the user doesn't have to …

Member Avatar for WaltP
0
188
Member Avatar for purpleturtle_97

I've been stuck on this for hours because I really don't understand file descriptors and how successfully print a file to one. Basically, I want to be able to open a file and then echo its contents a character at a time to a socket file descriptor. The code below …

Member Avatar for Narue
0
207
Member Avatar for DJWK

This program should extract the first line. Somehow I'm getting the last line instead of the first... This is the textfile: [ICODE]N100 G96 S200 N115 G0 X600 Z-1004.95 T11 D2 M3 M7 H10 N125 G0 X500 N130 G1 X419 F0.5 N135 G1 Z-1004 N140 G0 X500 N145 G0 Z-419.7 N150 …

Member Avatar for DJWK
0
223
Member Avatar for coril

I'm trying to read user input and store it as a string including the whitespace. I did a search for a solution and was pointed to fgets() or scanf(%[^\n], str). But both these solutions give me an error. This is what I have: [CODE] scanf("%d", &input); if (input == 1){ …

Member Avatar for Narue
0
1K
Member Avatar for spark69

Hello, I have two very simple questions. 1. I want to use fgets(text, MAX_WORDS, stdin) to read in a string file, where my array is text[MAX_WORDS]. But is there a way to make stdin a pointer instead to a 2nd array which can be a buffer? 2.Whats the difference between …

Member Avatar for Narue
0
580
Member Avatar for d_panayotov

Hello, I have this assignment in C. The problem is that the functions have to be placed in separate files instead of just one. I haven't done that before. It seems code that would have run if the program was written in one file doesn't work when the functions are …

Member Avatar for d_panayotov
0
167
Member Avatar for baldwindc

Could someone please explain the following code to me? It's not for class, more personal curiosity. Thanks in advance [code=cpp] while(!feof(infp)) { fgets(buf, MAXLINE, infp); fputs(buf, outfp); } [/code] what I'm mainly curious about is the argument o feof "infp."

Member Avatar for Ancient Dragon
0
146
Member Avatar for Kevin_160

Hi Everybody, FYI (In order to get a feeling with the time it takes to send command strings to signal generators via a GPIB bus, I want to send a voltage level high pulse to an oscilloscope. Ones the RF signal arrives via a detector diode, The pulse and the …

Member Avatar for Kevin_160
0
341
Member Avatar for wackozacko

Ok, so I'm trying to write an emulator for a simple processor architecture and I've ran into a strange problem. I decided to read the input code once through to see how many lines there were, then set up an array of that length, and then go through the file …

Member Avatar for Aia
0
2K
Member Avatar for aianne

Hi! I need help to my Turbo C program.. I need to create a program that will ask the "Starting X:", "Starting Y:", Ending X:", and Ending Y:" on different shapes.. this is how the program should be: [CODE]SQUARE: starting X: starting Y: ending X: ending Y: CIRCLE: Starting X: …

Member Avatar for Top9ne
0
1K
Member Avatar for dondajr

Hi again. I have a file that have about 1000 lines, and then, time by time I need to read some of this lines, for example: 13:00:00 read lines 01 to 100; 13:30 read lines 101 to 400; .... 15:00:00 read lines 900 to 1000. There is a way to …

Member Avatar for dondajr
0
109
Member Avatar for lionaneesh

[CODE] #include<stdio.h> int main() { FILE *reading; FILE *writing; int condition,condition2; char input[100]; char save[100]; printf("Type a name to open for reading : "); scanf("%s",input); reading = fopen(input,"r"); /* OPENS the file name we typed above for reading */ if(reading != NULL) { do { condition = fgets(save,30,reading); printf("\n%s",save); }while(condition …

Member Avatar for Aia
0
126
Member Avatar for Dave Sinkula

Some issues, such as leading whitespace and trailing characters that cannot be part of a number, were not handled in [url=http://www.daniweb.com/code/showsnippet.php?codeid=266]Read an Integer from the User, Part 1[/url]. Here such issues receive lip service.

Member Avatar for drxs33
1
461

The End.