1,088 Posted Topics
Re: Variables in the shell are strings. Another utility is necessary to make the evaluation. [B]expr [/B]can do it, but has many "gotchas" that you need to be aware of, [I][B]e.i.[/B][/I] spaces, (), *, which need to be stripped of its especial meaning. [CODE=ksh]result=$(expr \( \( $obyte2 - $obyte1 \) / … | |
Re: >Are they absolutely necessary to use them when passing arrays from functions ect. or is it just a more efficient way of doing so? It is the only way you can pass by reference. Further ahead in you education you'll learn that pointers shine when they are used in conjunction … | |
Re: [QUOTE=nucleon;799762]You need to increment the array index to point to the next element for each character read. Here's an example.[/QUOTE] A problem that arise of giving what appears to be a full working example is that normally it gets taken like correct and proper working code, free of bugs and … | |
Re: >strncat(command_array, cmd, 100); //error on this line First let me ask you: what's in command_array? command_array can only hold 20 chars including the '\0' of which we don't know the content since it hasn't been initialized. You are asking strncat to inject to it a 100 char more from cmd, … | |
Re: >Basically, I want to know why the second script returns the line: >[ICODE]Total size of files containing foo is: 0[/ICODE] [URL="http://www.nucleardonkey.net/blog/2007/08/variable_scope_in_bash.html"]Variable scope[/URL] problem in the while loop with | (pipe) More [URL="http://nion.modprobe.de/blog/archives/531-Altering-a-variable-outside-the-scope-of-a-loop-influenced-by-a-subshell.html"]here[/URL]. | |
Re: >may be its just a matter of luck and compiler sometimes. Yeah, like playing slot in Las Vegas. It's all about luck and compiler, right! | |
Re: [QUOTE=priyankasaini;798907]please write a programme to sort array of integers using quick sort[/QUOTE] No, you write it. | |
Re: >C just sucks!!!! Correction. You suck at C. Post the complete pertaining code. | |
Re: [QUOTE=Ancient Dragon;797915]There is a great deal of truth in that video. I have dish network tv with over 100 channels to choose from, and there are days when there isn't a thing that I want to watch.[/QUOTE] The remainder deal of falsehood must be compelling enough for you to not … | |
Re: Related to: [ICODE]n=(NODE)malloc(sizeof(struct node*));[/ICODE] Casting malloc is not necessary if the proper header file stdlib.h is included. Fail to check for a successful return of allocated memory. Fail to release dynamic memory. The code indentation has room to improve. | |
Re: [QUOTE=Skorpion;795105]no suppose i tell u to print the odd numbers from1-20 then u have to print only odd numbers like 1 3 5 7 9 .....19 but the user can give u any point[/QUOTE] Whether in recession or not, you don't need to save characters. It is alright to say: … | |
Re: strchr() can find where the period is, the rest is the decimal part. strtol() can convert the decimal part into a long int. | |
Re: [ICODE]scanf( "%s", str);[/ICODE] will never include the newline into the string `str'. scanf() is designed in its default form to stop reading when it finds a space or newline. Bottom line. scanf() is a poor choice to read input string from stdin. fgets() is a favorite of many. | |
Re: Where's your question? Furthermore, this is a forum for the C language, and you are showing us an aberration of C++. Use proper code tags when posting source code. Read the rules or you'll be ignored. | |
Re: To encrypt: while string iteration of char = iteration of char + pre-determined character To decrypt: The opposite. | |
Re: Salem gave you a hint already, but if you feel you need more I'll give you another. [URL="http://www.daniweb.com/forums/post364516.html#post364516"]Search for your answer first![/URL]; the first point from Read This Before Posting, at the head of the forum. | |
Re: John, Manager, Finance, [COLOR="Red"]$[/COLOR]2000 Jack, Accountant, Finance, [COLOR="Red"]$[/COLOR]1500 If you take off the $ sign from the field value it might work. [Edit] Don't disregard Salem's advice. You're lucky I didn't noticed it before. I usually don't entertain posts from people that willingly ignores the forums conduct. | |
Re: [QUOTE=death_oclock;787602] Wave.h: [CODE]#ifndef WAVE_H #define WAVE_H typedef struct { unsigned short formatTag; unsigned short numChannels; unsigned int samplesPerSec; unsigned int bytesPerSec; unsigned short blockAlign; } WAVE_INFO; typedef struct { WAVE_INFO *info; SAMPLE *data; } WAVE_FILE; [COLOR="Red"]bool getWaveData(WAVE_FILE *file, char *filename) { // function body, not important } void extractWaveFrames(FRAME *frames, … | |
Re: >what is the meaning of that? Your computer is mad at you for asking it to run a object file that for some reason doesn't exist. >and what should i do? Get your hands off the keyboard and step away from the computer. >please anybody help me. If you want … | |
Re: >it does not work perfectly i don't know why That is a superfluous statement. It doesn't explain what the program is supposed to do. It doesn't explain what is doing that you don't want it to do. >but when i separate it its working.. And then you give us the … | |
Re: [ICODE]scanf("%[^\n]",str);[/ICODE] Do you want to bet I can overflow the 15 characters that str[] can hold? I would accept ( if I don't care about any extra left in the buffer ) that [ICODE]if ( scanf("%14[^\n]", str) == 1 ) [/ICODE]can fulfill the upper limit, but that's about it. Posting … | |
Re: Impossibility is playing a role in your distress. You could not have been born in two different months, nor could you have been born in a day that is earlier and later that a significant period, at the same time. There's an order of precedent as well to take in … | |
Re: In order to understand the sexual reproduction of snails, you must understand a key word: "hermaphrodite". Not the answer expected? Well, that's what you get when you don't ask any question. To hone the answer down, you need to be explicit. Use C language code tags to wrap your source … | |
Re: >following function can be easily written as: No!, it can not be written as easily. [ICODE]char *s;[/ICODE] is a pointer to a char and you can not write to memory that it hasn't been allocated to it. Thus,[ICODE] scanf("%[^\n]",s);[/ICODE] is wrong, and so is [ICODE]p=strtok(s," ")[/ICODE]; since strtok need to … | |
Re: >I wrote this program and I need to know if I didn't make a mistake Would you care to know if you did? [ICODE]void main()[/ICODE] is in opposition to the standard. It should return an integer. Therefore the proper code would be[ICODE] int main(void)[/ICODE] in your case. It is time … | |
Re: [QUOTE=atman;781628]depends on the pass if its the first pass then 0, if second then 1, e.c.t...[/QUOTE] Nope. That [B]i[/B] has the value of "segmentation fault". It never gets initialized. If you want to pass it a value you need to do it as an argument. [ICODE]void enter(int *p_arr, [COLOR="Red"]int i[/COLOR]);[/ICODE] … | |
Re: >i want to write a code so that output will show the dept name and no. of employee in that dept in the tabular form. Start doing it, and stop wasting your time posting the assignment. Show us your efforts. | |
Re: >please give me all your help i need this soo much its my exams tomorrow and i really need help.thanks in advance! Sure, tell me the e-mail of your professor at school and I'll ask him to give you a break. | |
![]() | Re: Read your reference material about how the standard fscanf() function works. While your are there, read about gets() as well. If it is a good reference it would tell you to never use it. |
Re: Whenever you log-in or open a new terminal window that starts the shell to run, a series of scripts are executed to establish the environment in which it is to run. These scripts contains commands just like if you were to execute them in the command line. ~/.bash_profile and ~/.bashrc … | |
Re: Your indentation could use some more noticeable spaces. [ICODE]#include<conio.h>[/ICODE] is not a standard header file. [ICODE]clrscr();[/ICODE] and [ICODE]getch();[/ICODE] are not portable C standard functions. [ICODE]void main()[/ICODE] should always return an int, except when there's not host operating system. [ICODE]printf("enter the name:");[/ICODE] you ask for a name, but expect six to … | |
Re: [QUOTE=Freaky_Chris;781150]Do you feel the need to echo me?[/QUOTE] It is not uncommon for two people to post about the same solution or idea, without knowing or being aware of each other, since the browser doesn't refresh until the post has been committed. | |
Re: main() returns an int. Why? Click [URL="http://www.daniweb.com/forums/post764936-4.html"]here[/URL] gets() is not a function that you should use. Why? Click [URL="http://www.gidnetwork.com/b-56.html"]here[/URL]. Some improvement in proper indentation would make it easier to read. Click [URL="http://www.gidnetwork.com/b-38.html"]here[/URL]. | |
Re: [QUOTE=vmanes;779133]And the point would be?[/QUOTE] To make better highways for air planes. They should patent the technology, you'll never know when the idea might "sky-rocket". | |
Re: Could you post what you have done so far? In that way we'll know at what level you are at learning, and tailor a help for you. Make sure you read the proper way of tagging code before hand. | |
You ain't seen nothing yet. But [URL="http://news.cnet.com/8301-13578_3-10133425-38.html"]this is[/URL] part of the promised change. | |
Re: [QUOTE]Police say that such methods are necessary to investigate suspects who use cyberspace to carry out crimes. These include paedophiles, internet fraudsters, identity thieves and terrorists.[/QUOTE] These days, any state craving control over citizenry thinks that throwing the word "terrorist" or "a variation for undesirable" is justification enough. The sad … | |
Re: [B]@ Marks256[/B] [quote]Does anyone here own the book (Programming Windows by Charles Petzold fifth edition)? If so, can anyone give me some ideas of what they cover (at how much detail is given)? I am literally starting to panic... [/quote] Check your mail box, I sent you some information about … | |
Re: >Why do you think i should rethink whole function? Could you be more specific? You are passing copies of arguments that don't need to be passed as parameters? Indexes like i and j don't need to be part of arguments in a function; they can be local declared to the … | |
Re: [QUOTE=jinsonsani;771183]I want to replace a text in a file eg (old_text) with another text eg (new_text) . new_text is a variable in my shell script. few methods that i tried .. but this doesnt work cat $line".sh" sed -e 's/abc/ABC/g' $line".sh" sed 's/ordprg/new_string/g' $line".sh" > $line".sh" Could some one can … | |
Re: >any chance you could explain what I was doing and what strcpy() does differently, just for future reference? [CODE]char *linep = malloc(sizeof(char) * 1000);[/CODE] malloc sets apart the memory you specified. And you keep track of that memory via the pointer [B]linep[/B] But that pointer can be reassigned to point … | |
![]() | Re: [ICODE]fscanf(inFile, "%s", text)[/ICODE] Think for a moment, what does text need to be? |
![]() | Re: Have you first tried to learn how linked lists work? [URL="http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]Here[/URL]. |
![]() | Re: [B]Please help me fix these errors[/B] is the perfect title to be ignore. Next time avoid such "Please, help me" titles. >"error C2664: 'sprintf' : cannot convert parameter 2 from 'int' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast" [ICODE]sprintf() … |
Re: >I have been afraid of Vim editor, due to NO-knowledge. Practice will change that. Learn as you go according to your need. Vim has much to offer, but until you start using it, you'll will not know what it is applicable to you in your way of writing. Thanks for … | |
Re: [QUOTE=sneekula;769500]There is "no beauty" in even simple C code! [/QUOTE] "Beauty is only in the eye of the beholder". Those that know, find a well written piece of code in C very motivating and easy to work with. The comparison of languages as it has been described here, only shows … | |
Re: ...And they lived happily ever after. [B][I]The end[/I][/B]. | |
Re: Group: [0-9]\n{1}#.*$ Setting aside the fact that that regex would not match any of the text you gave as an example, the key to understand your problem is `.*$`. That's a greedy "match regex", it will match any character until it encounters the end of line; not the first one … | |
Re: [QUOTE=EZO;765869]Peace... Can anyone explain that more, step by step.[/QUOTE] [B]First[/B], you read the date that conversation was initiated. [B]Second[/B], you start a new thread, making sure you have done your part to follow the rules of posting. [B]Third[/B], you link or point to the old conversation, if it is relevant … |
The End.