1,088 Posted Topics
Re: >Everything works fine but for the address I need more than 1 word, separated by space, so I tried using the getchar() function. Yes, this is a classic. scanf() is very lousy for obtaining string input from user. It can handle spaces but not by default, and it is prompted … | |
Re: BTW Drop the & in scanf(), it is either [ICODE]scanf("%s", name)[/ICODE] or [ICODE]scanf("%s", &name[0])[/ICODE], but not scanf("%s", [COLOR="Red"]&[/COLOR]name) | |
Re: [QUOTE=cwarn23;1082187] Does anybody know how to define a mixed variable?[/QUOTE] There's not such a thing as mixed variable. Variable overloading does not exist in the C language. | |
Re: >I am all confused, I don't where to start. Declare a variable that will keep money amount. Ask the user for money amount. Read the input. Process the input in a function to determined how many bills of each class needs to be outputted. | |
Re: [QUOTE=milanese;1079035]Hi, [code]@echo off SET Day=%date:~0,2% SET Month=%date:~3,2% SET Year=%date:~6,4% SET cdate=%Year%%Month%%Day% SET localDir=D:\New_Files SET newDir=D:\test COPY "D:\New_Files\*.dat" "D:\test\*.dat" pause rem dir c:\windows[/code] [/QUOTE] The way you are setting the variables of day, month and year are incorrect. [CODE] ECHO %date% Wed 12/16/2009 [/CODE] Therefore 16 would be the day which … | |
Re: [QUOTE=javaStud;1077531]yes I have understood. Now that I have removed the while statement, I am still encountering the same problem (printing only 0s). Could it be that as an output I am getting only the first byte of the frame, or am I displaying the array incorrectly? Thanks a lot. [/QUOTE] … | |
Re: [QUOTE=xavier666;1069864]Points to be noted, raghuhr84 [list] [*]Give the complete program, that is, give [icode]#include<stdio.h>[/icode]. Becomes easier for us to check. [*]Use proper indentation [*]Use code tags around your program (See the forum rules) [/list] The problem is that you have not flushed stdin. Put [icode]fflush(stdin);[/icode] before the [icode]scanf[/icode]. That should … | |
Re: Is that a tricky question? Why don't you run it and find out? | |
Re: That's not help. That would be doing your homework for you. Read the forum rules. You need to show effort, and what better way than posting the code that you have tried so far? | |
Re: You missed to read the rules of the forum. We don't give any code away without you posting what you have done to show effort. | |
Re: [QUOTE=Mattpd;1053048] This script below gives me the proper result, but I had to cheat to do it. I just substituted "OUT:06/12/2007:MATT" for "IN" and appended it to the file.txt and then deleted the entire old line. Only problem is that the line is now at the end of the file … | |
Re: [QUOTE=hookah;1063281]i can nt belive no one can help me in this. No one knows c in here[/QUOTE] We don't do homework. Read the forum rules. And what you believe or do not believe is irrelevant. | |
Re: isxrc> PLS PLS PLS can someone help. I have 24 hours from now and the clock is ticking. The urgency is on your part, not on ours. You have chosen to fail already. Read the rules of the forum. We do not give away code solutions without proof of effort … | |
Re: Some points for now: [CODE]newPtr = malloc(sizeof(job)); /*create new node*/[/CODE] What's job? I don't see job anywhere. [CODE=c] if ((jPtr = fopen("jobticket.txt", "w"))== NULL) { printf("File could not be opened\n"); } fclose (jPtr);[/CODE] Doesn't make any sense regardless the file gets opened or not you close it right away. You … | |
Re: [QUOTE=Narue;1060207][B]>but still compiled and ran without incident.. [/B] Yet another ding against gcc for not conforming to the standard, I suppose. Those switches put the compiler in strict conformance mode, which means a constraint violation like this would be rejected outright.[/QUOTE] [B]-ansi[/B] switch, all that it does is to support … | |
Re: [QUOTE=crunchie;1042598]C'mon ppl. Give me at least [i]one[/i] vote :D[/QUOTE] You are worthy of more than one. There! | |
Re: [QUOTE=richman0829;1054570]For me, it's Quest For Fire. I really got involved with the characters (even learned their language!), and in the final scene, I just had to be grateful I had ancestors like them, or I wouldn't be here typing this.[/QUOTE] Quest For Fire, definitely, an entertaining movie. However, you realize … | |
Re: [CODE]sed -e [COLOR="Red"]"[/COLOR]s/[COLOR="Red"]$[/COLOR]old_string/[COLOR="Red"]$[/COLOR]new_string/[COLOR="Red"]"[/COLOR] file1.txt > file2.txt[/CODE] | |
Re: [QUOTE=naziatarannum;1056903]Hi all, I have a simple question as it appears. But am unable to get the solution. Question is -how do I get the access time of a file in unix. please advise on the command. Thanks[/QUOTE] [ICODE]stat[/ICODE] might give you what you want. | |
Re: [quote=qaisu;339997]Well C is too old for 2007[/quote] I disagree. Let's say you want to develope harware drivers; what program lenguage dominates there?. Let's say you want to develope operating system kernels; what program do you think is used? Anything that has to do with "closer to the metal" C is … | |
Re: [CODE]scanf("%[COLOR="Red"]f[/COLOR]", &length);[/CODE] length is an int, you are passing a float. Same with [ICODE]scanf("%f", &breadth);[/ICODE] Either you change the type in the declaration of length and breadth, or change the[ICODE] f [/ICODE]to[ICODE] d [/ICODE]in the calling of scanf(). | |
Re: [QUOTE=Mattpd;1042106]I am trying to delete any line of text that contains "$npname" and the word "in." The script works if $npname is only one word, but if it is more than one work I get "error: unterminated address regex" How can I fix this? [CODE]sed '/'$npname'.*in/d' parts.txt > parts.tmp[/CODE][/QUOTE] It … | |
Re: [QUOTE=jk2005.jeeva;1048400] [COLOR="Green"]int[/COLOR] main([COLOR="Green"]void[/COLOR]) { int x=20,y=35; [COLOR="Red"] x=y++ + x++; y= ++y + ++x; [/COLOR] printf(“%d%d[COLOR="Red"]\[/COLOR]n”,x,y); /* is should be \n */ [COLOR="Green"]return 0;[/COLOR] } [/QUOTE] Those two expressions invoke undefined behavior. Anything can be the result. It is best if you write [COLOR="Red"]int[/COLOR] main(), and [COLOR="Red"]return[/COLOR] inside of main … | |
Re: [QUOTE=naziatarannum;1048468]Hi, Please help in this regard. Can the modification time of a file be updated to any date of our choice? Please advise. Thanks in advance![/QUOTE] Look into the command [ICODE]touch[/ICODE] | |
Re: [QUOTE=Soileau;1049212][CODE]#include <stdio.h> struct poly { int len; int arr[3]; /* this must have a defined size, three for example */ char *name; }; int main() { int i; struct poly p; p.len = 45; /* p.arr[3] = {1,1,1}; p.arr[3] is only one integer, you can not load three into it … | |
Re: Click [URL="http://www.daniweb.com/forums/post1048411.html#post1048411"]here[/URL] and [URL="http://www.daniweb.com/forums/post1049104.html#post1049104"]here[/URL]. | |
Re: [QUOTE=timaquerra;1048427]is it possible to put void function into loop statement?[/QUOTE] Yes, why do you ask? There must be something else you want to know. | |
Re: [QUOTE=naziatarannum;1043636]hi Scott, Am getting this error for the code [code] Missing ] [/code] Please help[/QUOTE] Post your code the way you wrote it to execute. Make sure there's a space between [ and ] | |
Re: [QUOTE=hosh;1048346]Hi i'm trying to compile this code, but getting warning. need some help to understand what I'm doing wrong. [/QUOTE] Instead of [CODE] out = fopen ([COLOR="Red"]out[/COLOR], "w");[/CODE] it must be [CODE]out = fopen ([COLOR="Red"] filename[/COLOR], "w" );[/CODE] where filename is a string with the path to the file you … | |
Re: [QUOTE=vampgirl13;1047470]Hi, I was wondering if anyone can help me translate this into java. Thanks [/QUOTE] There's not such a mechanism of translating C to Java, except for the most rudimentary and simple statements. Since both languages are different, all that it can be done is to understand what the program … | |
Re: [QUOTE=gerard4143;1047847]This function returns the address of the local variable str [/QUOTE] Variable str is created when the function leer() is used. It is [1]destroyed when the function leer() is finished. You are returning a pointer to that memory that might or might not contain the previous declared value. [1] nothing … | |
Re: [QUOTE=imolorhe;1045072]Please i need d code for C.[/QUOTE] The rules of this forum clearly explain that we do not give away code to posters that do not show proof of effort. Where's the code? Where is your effort in the matter? | |
Re: What's the trouble? In its simplest form, create another executable script with three lines of text, where each line is the absolute path to those three scripts. | |
Re: [QUOTE=thure;1043316]That dismissed one of the warnings, but I still get a segmentation fault at [CODE]reply->option=o;[/CODE] Why is that even a problem?[/QUOTE] [ICODE]struct REPLY *reply;[/ICODE] is a pointer, anything you try to write to it it will produce a segmentation fault, since there's no memory allocated for it. | |
Re: shakunni >Anyone know why this is the case? A function must be called from another function block which could be the main function or one with a lineage to any main function. Meaning that main() must have been called first at some point. malloc() is a function and you are … | |
Re: [QUOTE=FIG-GHD742;1044020] Can i edit or mark this thread as finhis?[/QUOTE] When you are the original poster you'd see at the bottom, after the last post, the mark as solved title, in blue. Click on it. | |
Re: [QUOTE=Mattpd;1043573]If I have two lines of text: HOOK HOOK HOOK what is the syntax to grep just the first line without the second? and the second without the first?[/QUOTE] Find any difference between both and then match it. [B]e.g.[/B] with HOOK by itself in a line we can match the … | |
Re: To save the transaction you are almost there. [ICODE]int bal = 0; /* initialize balance to zero */[/ICODE] instead of[ICODE] bal = 0 + credit; [/ICODE]replace for [ICODE]bal = bal + credit;[/ICODE] or [ICODE]bal += credit;[/ICODE] which is a shortcut. | |
Re: [CODE]system("PAUSE")[COLOR="Red"]:[/COLOR][/CODE] | |
Re: [CODE]if( line == pattern)[/CODE] That's a no-no, since line and pattern are strings and you can't compare arrays in that way. Take a look at the string function strcmp() for that. However, even if that would be correct, line is bound to have more characters read into, that the pattern, … | |
Re: The controlling expression of a switch shall have integer type. An array of chars will not do. | |
Re: [CODE] if (data_size == SIZE_32 ) { * ( ((int32_t*)(new_node->data)) + index) = (int32_t) index*2 ; * ( ((int32_t*)(new_node-> data)) + index) = (int32_t) index*3[COLOR="Red"];[/COLOR] } else { * ( ((int64_t*)(new_node-> data)) + index) = (int64_t) index*4; * ( ((int64_t*)(new_node-> data)) + index) = (int64_t) index*5; } [/CODE] What's the … | |
Re: [QUOTE]hope you can help me with some advice. [/QUOTE] First, you must understand what constitutes a string in C. It is a sequence of chars terminated with a '\0'. So if I have this: [CODE]char fullname[] = "Jiminy Cricket";[/CODE] and I want to split it into name and last name, … | |
Re: [QUOTE]How would you refer to the w in web at frases[1]?[/QUOTE] [CODE]frases[1][5];[/CODE] or if you want to complicate it [CODE]*(*(frases + 1)+ 5)[/CODE] | |
Re: [CODE=c]fgets( student[count_s].name, sizeof (student[count_s].name), stdin );[/CODE] | |
Re: [QUOTE=neithan;1029016]Oh, google, how didn't i though of that? [/QUOTE] Google: the response to much and the answer to nothing. | |
Re: Dear Sir/Madam: Certainly, you made the right choice to select this forum to ask your C programming questions. Nevertheless, you skipped two important requirements that must accompany YOUR posting questions. ~ You did not include any source code showing the trouble area of inquiring. ~ You did not read (or … | |
Re: Take a look at its prototype. What type does getch() return? | |
Re: MONTH and MES are arrays of pointers to read-only memory. The value they are pointing to it can not be modified. It works the same way than if it were single pointers. [CODE]char *dia = "Lunes"; /* Lunes can not be changed because is a piece of memory fixed as … | |
Re: [QUOTE=Tom Gunn;1028577] [code] void PauseForUser(int promptUser, int clearStream) { if (clearStream) { int c; while ((c = getchar()) != '\n' && c != EOF) { /* all work in condition */ } clearerr(stdin); } if (promptUser) fputs("Press [Enter] to continue", stdout); getchar(); } [/code] In your code it might be … |
The End.