1,088 Posted Topics
Re: [QUOTE=theprofoundgeek;1024008]Yeah, Gaiety, its always preferable to type cast the data type then convert it in every instance of accessing the data. (At least this is what I have been told up to now!)[/QUOTE] Casting the return of dynamic memory allocation functions should not be made a habit of, in C. … | |
Re: [QUOTE=Gerbilkit;1026571] As I said I have no clue what # $1 !~/^#/ { means, I found it on the internet and popped it in since it made lots of syntax errors go away. :P [/QUOTE] Your logic for including the matching pattern escapes me, however I can explain it to … | |
![]() | Re: [QUOTE=Odc;1026346] I am trying to read integers from a file and store them into an array but I have no idea how to do it. [...][/QUOTE] One step at a time. Start learning how to assign values to arrays. Learn how to read a single or group of characters from … ![]() |
Re: So you think you solved it? Enter... let's say: "H" or better yet "3.s" and tell us back what's the behavior you observed. | |
Re: [QUOTE=Arcaiz;1022276] fgetc returns char type but your array is int type. Maybe that's the problem[/QUOTE] [ICODE] fgetc() [/ICODE]returns an integer as it is prototyped [code=c]int fgetc ( FILE * stream );[/code] flyballonfly> however I am still getting the seg fault on the same line. [CODE]int j,i,temp,[COLOR="Red"]numSegs = 0;[/COLOR] FILE *infile … | |
Re: [QUOTE=needhelpe;1020904]hey I need help. I made one code but doesn't work!!![/QUOTE] Can we see what you have done so far? | |
Re: [QUOTE=hosh;1020069]Hi, can anyone help me to solve this problem? I have this code: FILE *in; char i =fgetc(in); int perm=0; perm =atoi(&i); printf("%d\n", perm); if first character in my "in" file is 2, the output is 28; if ------------------------------- is 3, -------------- 38, and so on... any ideas what is … | |
Re: [QUOTE=OSiRiSsk;1010927]well but i will read multiple lines, so how to make this code right ?[/QUOTE] Perhaps another approach? [CODE=c]#include <stdio.h> #include <ctype.h> void clean_spaces(void); int main(void) { clean_spaces(); return 0; } /* * clean_spaces will leave only the first space found and it ignores extra * instances */ void clean_spaces(void) … | |
Re: Hi, i need some help. i have an assignment on "Airline Ticket Reservations System". i have to submit it on 10th August, 2008. I tried but can't solve it. please help me. The question is given below : 1. Consider a new airline agency “BEST AIR” that launches recently in … | |
Re: [QUOTE=ahaZohan;1014353]Hi, I have 2 arrays and i want to put them in one array. array1[10]="hello" array2[10]="you" array12[10]="hello you" How can I do this. Many thx![/QUOTE] Study the C standard function [URL="http://www.cplusplus.com/reference/clibrary/cstring/strcat/"]strcat()[/URL] or its cousin strncat(). Those two functions are designed to concatenate strings. strcpy() might be needed to copy the … | |
Re: [QUOTE=hket89;957371]What is the purpose of using call by value and call by reference?[/QUOTE] Your question revealed that perhaps you are not understanding what it has been explained so far. There's not such a thing as call by reference in The C language. Everything done is done by coping values around. … | |
Re: [QUOTE=geoffy0404;1012540]I know my problem is within the SWITCH CASE!![/QUOTE] Plenty of thing are erroneous in your snippet, however I would like to point out the cause of your affliction for now. [CODE]printf(" A - Addition\n S - Subtraction\n M - Multiplication\n D - Division\n Q - Modular\n"); /* use scanf … | |
Re: scanf() reads the integer but leaves the `ENTER or RETURN' key you pressed, in the stdin buffer. That key is seen by fgets() as a newline and that's what it reads, not waiting for the user to interact. Inserting a getchar() between scanf() and fgets() does eat that left-over newline, … | |
Re: >I don't understand what's wrong with assigning the value 0.1 to a float variable . There's nothing wrong with it, the compiler is warning you that you are trying to assign a double to a float. A literal 0.1 is a double in your compiler. Do a test. Add these … | |
Re: [CODE=c]#define ADDITION = addition #define SUBTRACTION = subtraction #define MULTIPLICATION = multiplication #define DIVISION = division #define MODULAR = modular [/CODE] Find what's wrong with those | |
Re: [QUOTE=sweetjhin;1010850]I'm not actually looking for a quick answer to my homework. That's why I asked this question because I was hoping that I could find a program that would display the whole calendar. Right now the program I made is just displaying one month and I don't know how to … | |
Re: [QUOTE=dkalita;1008793]U can do the same as follows: [CODE] void write(char string[]) { int i; FILE *file; char *strTemp=(char *)malloc(strlen(string)+1); /* * Where would be that pointer be pointing to if malloc is not successful * allocating memory? You must always check for the return of malloc. * casting malloc is … | |
Re: [CODE]+--------------------------------------------+ | | X | |--------------------------------------------| | CONGRATULATIONS! | | | | You are the lucky moron of the moment, | | by ignoring forum rules. | | Click OK to claim your price. | | | | +------+ | | | [URL="http://www.daniweb.com/forums/announcement118-2.html"]OK[/URL] | | | +------+ | +--------------------------------------------+[/CODE] | |
Re: [QUOTE]The definition of the ‘C’ Library function memset is void *memset(char *s, char c, size_t n) Copy c to the first n characters of s. Return s. [/QUOTE] The proper prototype is [ICODE]void * memset ( void * ptr, int value, size_t num );[/ICODE] [QUOTE]void *memset(char *s, char c, size_t … | |
Re: Here's an assignment. Search why [CODE]gets(s[i]);[/CODE] is a no no. What is it that you are sorting the names by? | |
Re: [QUOTE=VernonDozier;991659]I have a data file that, if I was using C++, I would use the getline function to read its data into the proper variables. However, the getline functions that C++ allows appear to not be available to me in C. I want to be able to specify a stream, … | |
Re: [CODE]fopen("C:[COLOR="Red"]\d[/COLOR]ata[COLOR="Red"]\d[/COLOR]ef.txt","r")[/CODE] If you don't double it, the compiler is going to try to interpreted as the character \d which is wrong. strtok() is a silly function with limited utility in reality. It looks for the given characters and when it finds a first success, it changes as a NULL. Which … | |
Re: [QUOTE=rocky420;985341]Files Infected: C:\WINDOWS\system32\SKYNETlog.dat (Trojan.Agent) -> No action taken.[/QUOTE] SKYNET is used as part of rootkit technology which will be hard to clean unless you understand what's going on. Maybe [URL="http://www.malwarebytes.org/forums/index.php?showtopic=12709"]this thread[/URL] will do just that A solution I find more secure is to boot with [URL="http://www.softpedia.com/get/System/Boot-Manager-Disk/UBCD4WIN.shtml"]UBCD[/URL] and open a terminal. … | |
Re: [QUOTE=azn_sweet;978779][code] /*Output Section */ printf ("\nThat height is equivalent to " "%1f" " feet and " "%2f" " inch(es).\n"); scanf ("%f", &FEET); scanf ("%f", &INCHES); [/code][/QUOTE] This is how you add quotes to the specifiers and those are the correct parameters if you want to control the output of the … | |
Re: >I don't really know where he is coming from. Is it that hard to understand where he's coming from? From a security, privacy and freedom stand point. >That sort of commodity service doesn't sound stupid to me. So much focus it has been shown already to the word stupid. And … | |
Re: >Third world countries don't deserve cutting edge technology. Better to remain silent and be thought a fool than to speak out and remove all doubt. | |
Re: >What's next, defending murder as "freedom of expression"? No need, we have other terminology: "self-defense war" | |
Re: Foxit Reader is a favorite of mine from sometime already. I like the way it opens pdf right away. | |
Re: Much coverage for so little content. That's what I see on all this blogging about Microsoft donating a mere $100.000, which it barely will cover the year-salary of one full time developer. As far as Microsoft goes they got their money worth times over in PR and exposure value. | |
Re: I wonder if the Open Source community will still be arguing about the name. What's it going to be? Linux/Skynet or GNU/Skynet? In any case you have gave me reason to be worry of April 21, 2011. Just making fun! We all know that the end of The World would … | |
Re: I can not wait for the day they will open Windows 3.1, which I prefer over Windows 3.0 because the analog clock run much faster. | |
Re: >“what’s fair is fair.” Whao!. I would love to get paid as much as he gets just to be able to say these kind of profound statements. I am so moved that I'm thinking of giving him a big hug of support and condolences. | |
Re: [QUOTE=Dave Sinkula;962553]Perhaps it was just the chart I was looking at the showed postfix at higher precedence than prefix.[/QUOTE] Isn't this another case were we should not depend in the order of precedence between [I]sequence points[/I]? | |
Re: Passing values on a function is done by making a copy of it, which means the original is not modified. [CODE]int changeBandC(int b,int c) { int changeBandC = 0; /* This is wrong here delete it */ b = b + 1; /*the work is done in b which is … | |
Re: pymatio> I expected the of output to look like the file, whats wrong? Your understanding of how fscanf() works. pymatio> [CODE]while (fscanf(f, "%s", line) != EOF) { [/CODE] [ICODE]"%s"[/ICODE] won't read a line but rather until encounters an space, blank, tab, newline. | |
Re: [QUOTE=EvilOrange;956178]there is only 2 var missing and thats: char a; FILE *out; argv[2] is NULL which is why this bit of code comes into play[/QUOTE] [B]On the phone[/B] [B]Nick:[/B] Doctor, can you cure my cough? It is a horrible cough, I cannot sleep at night. [B]Dr. Hell:[/B] Sorry, Nick, I … | |
Re: >there are parts in between that I cut out but are irrelevant because compiler complains only about integer_part variable Make the variables [COLOR=Green]double[/COLOR] instead of [COLOR=Red]floats [/COLOR]and you'll be fine. BTW, main returns an int, so it should be [COLOR=Green]int main( void )[/COLOR] and not [COLOR=Red]void main( void )[/COLOR] | |
Re: [CODE]printf("\nyour is grade A",Total);[/CODE] Take a look at that one. Figure what are you missing. When you post code you need to wrapped around code tags to present it in a proper format. [URL="http://www.daniweb.com/forums/thread93280.html"]See here[/URL]. | |
Re: [QUOTE=9868;941173]Dont you think there is no chance in hell that f() will be called g() or h(), coz * has higher precedence than +. If f() is called first than, the whole purpose of precedency is lost.[/QUOTE] Precedence doesn't have any hold on them, since that behavior is undefined. | |
Re: [QUOTE=iamthwee;940799]Just make sure you flirt with the interviewer. If it's a guy, tell him that the way he sits turns you on. If it's a girl, say she smells good enough to eat. If they ask about programming just say you don't know anything at the moment because you're a … | |
Re: no1zson> What is wrong with GOTO? It usually is misused and it has the potential of making any code hard to debug and maintain. no1zson> What would you suggest in its place? Ideally, a sharp mind with the ability to design a flow control from top to bottom. | |
Re: If you take the time to read the rules on how to post and present your question, you might get better results. Start with [URL="http://www.daniweb.com/forums/thread78060.html"]this[/URL] and then go [URL="http://www.daniweb.com/forums/thread93280.html"]here[/URL] For convenience to the desperate and impatient those are shortcuts. | |
Re: [QUOTE=PetuniaRose;939155]I see folks replying to threads with quotes that have the name of the original poster included - they have the form nameOfPoster> quote [...][/QUOTE] I use that form in conversations when I need to bring focus to a particular portion of the quote. And I use the name from … | |
Re: no1zson> can somebody look at my IF loop (the first one for selcting 1-3) and see where I am going wrong? I am sure we can guess what you are trying to do, but don't you think it would be more effective if you tell us what is supposed to … | |
Re: yellowSnow> If this is the case, then perhaps you should try using the strtok() function. strtok() is a poor designed function, which make this recommendation a poor choice. | |
Re: EvilOrange> string[j][0] = string; <-- HERE IS THE PROBLEM string[j][0] is a space to hold a character string, on the other hand, is an array of characters. For sure there's going to be a problem if you try to push a bunch of character where only one can live. | |
Re: taikoprogrammer> How do you calculate powers in C If you are referring to especial operator, C doesn't have an operator for power. If you include the math.h file you may make use of the function pow() Otherwise you define a function that calculates the power the same way you would … |
The End.