1,088 Posted Topics
Re: >sunny╠╠╠╠╠╠╠ >do you know why this is? Most likely because no null terminator '\0' is finishing the string. | |
Re: Instead of : [CODE]sed -ie "\|^$JOBNAME\$|d"[/CODE] try: [CODE]sed -ie "0,/$JOBNAMES/{//d;}" filename[/CODE] The workhorse bit is "0,/RE/". It looks from starting line until first occurrence of REGEX >I really am a newbie to scripting but working hard to learn the way of the force. Here's [URL="http://www.tldp.org/LDP/abs/html/"]the tools[/URL] to construct your [I]"light … | |
Re: Could it be [URL="http://redwing.hutman.net/~mreed/warriorshtm/rottweilerpuppy.htm"]Rottweiler Puppy[/URL]? | |
Re: You know at least this is not C but rather C++, right? OP> the main errors are in with "for(i=0; i[COLOR="Red"]<[/COLOR]MAX; i++)" this part of the code but i can't see whats wrong. [ICODE]for ( i = 0; i [COLOR="Green"]<[/COLOR] MAX; i++)[/ICODE] is the correct syntax. | |
Re: OP> pls post the source code Yes, please, [URL="http://www.daniweb.com/forums/announcement118-2.html"]post the source code.[/URL] | |
Re: OP> In the print function it gives me this error: aggregate value used where an ineteger was expecter. Did you get why? [CODE]printf("O número de operadores livres é %[COLOR="Red"]d[/COLOR]\n",((int)nume - x))[/CODE] OP> I already tried to make a cast to int but it still give me this error. Casting is … | |
Re: [QUOTE=usman2k4u;841980]Write a Program to generate a random connected undirected graph on a n vertices by generating random pairs of integers between 1 and n. Compute how many edges are needed to produce a connected graph(as a function of n). Implement the union-find algorithm, with the Weighted Balancing and the splitting … | |
Re: [URL="http://www.linuxquestions.org/questions/programming-9/bash-programming-create-a-menu-307345/"]Maybe[/URL]? | |
Re: >or use it for your school work Yeah, tun it in for a grade. Don't be surprise of the [B]F [/B]afterwards. char word[10] scanf("%s",&word); Word is a string. So, you don't need the & in the scanf function. | |
Re: >the code is running but it i not deleting files. I'm skeptic that this script runs properly. To start [B]kiran.txt[/B] is in the same current directory that you are trying to delete *everything*. And just in case, DEL only deletes files, but not directories. | |
Re: [QUOTE=Narue;846819]>le sigh. :D It seems you've suffered enough for that bit of code, so I'll restrain myself.[/QUOTE] Must you? Could we encourage you to change your mind? For the good of the community, please? :D jephthah, don't worry I'll try to bandage you up afterward. :P | |
Re: >I don't hide the fact that I'm an jerk. I'm really good at it too. Go ahead, ask anybody on Daniweb. I'll wait. I am confused! The dictionary says: [B]Jerk[/B] - [I]a dull stupid. fatuous person[/I] Synonym: [B]dork[/B] - A stupid, inept, or foolish person. But I don't see any … | |
Re: This source code is plagued with syntax errors. [ICODE]printf ("word: <%s>\n", w);[/ICODE] requires the header file stdio.h [CODE]int set_keysig ([COLOR="Red"]type[/COLOR] s, [COLOR="Red"]type[/COLOR] ks, [COLOR="Red"]type[/COLOR] init)[COLOR="Red"];[/COLOR][/CODE] Prototype missing [B]; [/B]and type, where type is any data type like int, float, structure, pointer, etc. [ICODE]char s[[COLOR="Red"]x[/COLOR]];[/ICODE] length of string needs to be … | |
Re: [QUOTE=VernonDozier;706766] Whatever "Conservative" used to mean, if Conservative != Republican, then Conservatives should be really angry at the Republican Party because they've redefined the words to be synonyms.[/QUOTE] No political party has the monopoly of conservatism. If you keep bringing the Republican Party up, I am going to think you … | |
Re: >Where do these symbols come from? Like the Origin of Life, some call it a mystery; others call it a miracle. [CODE]printf ("There are %d vowels. They are: [COLOR="Red"]%s[/COLOR]\n", vCount, vowels);[/CODE] vowels is never terminated with the '\0' which would have made it a string. Forcing printf() to keep displaying … | |
Re: [QUOTE=vicio;791425]...and who said Osama was the leader of the group that hit the twin towers? I think you need to do some deeper research. It was Mussad people who did it![/QUOTE] Research is as foreign to his understanding as writing would be to a monkey. And this is not an … | |
Re: >That's not entirely true Repeating code unnecessarily, and stubbornly forcing the use of a function that was not designed to be used as it would have been in Pascal/FORTRAN. No wonder the practice keeps popping up all the time, since people that knows better continue to perpetuate the "possible" use … | |
Re: [QUOTE]#include<stdio.h> #include<math.h> int main(main) { printf("\n%d",main+=pow(++main,++main)); return 0; }[/QUOTE] >what does the above program do with "main"? A mockery of the C Standard, and a massive example of undefined behavior. | |
Re: Your script doesn't make any sense, however I am going to guess some. If you want to itinerate through the array ids you are missing something [CODE]for ((i=0;i<${#ids[COLOR="Red"][@][/COLOR]};i++)); do [/CODE] [QUOTE] > ${TMP} < ./results/$1${ids[${i}]}/test_error.dat[/QUOTE] That redirection is all backward. It would have been < inputfilename > outputfilename. However awk … | |
Re: [QUOTE]You can try this one...... char* str; while (fscanf(inp, "%s", str) != EOF) { [/QUOTE] What size of memory is [B]str[/B] pointing to? You don't know. You haven't given it any meaningful space of memory. Therefore you cannot use it with fscanf(), because it will overwrite unknown memory. | |
Re: >Do I have to take any extra measures to make sure the redirection is handled properly? Let's say you want to read some input and display it. [CODE=C]#include <stdio.h> int main(void) { int ch; /* read character by character from stdin */ do { ch = fgetc(stdin); putchar(ch); } while … | |
Re: Any argument passed in the command line is going to be a string as you seems to know. However, casting it to just an int is not going to help. You need to convert that string numeric representation into an integer. You could parse it using sscanf() or maybe convert … | |
Re: I don't know what the function [ICODE]gtk_button_new_with_label()[/ICODE] does since it is not prototyped in the code you provide, however, it appears that returns a pointer and not an int. Making all the errors part of the same problem. [QUOTE]vass.c:80: warning: assignment makes integer from pointer without a cast [/QUOTE] That's … | |
Re: >while(!feof(file)) I glanced very quickly to your last post and saw that. feof(file) would never give you the expected result as a loop control. See [URL="http://www.gidnetwork.com/b-58.html"]here[/URL] for some explanation. Furthermore that for loop will continue regardless if fscanf() can read a conversion or not. It should be able to stop … | |
Re: [code]cout<<unsort[i]<<" "; cout <<unsort[y];[/code] These are not valid C programming statements. | |
Re: [URL="http://linux.wku.edu/~lamonml/algor/sort/merge.html"]Merge Sort Algorithm Analysis[/URL] | |
Re: If I understand you correctly, you want to create variables dynamically at run time. No. It is not possible. C is strongly typed. Variables need to be declared before hand. | |
Re: Let's see if I can help you to clarify what you are doing. When you want to work in a file, you have to open it regardless it is for reading or for writing in it. The path where that file lives needs to be specified in absolute path if … | |
Re: [CODE]fscanf(fi, [COLOR="Red"]"[/COLOR]%f[COLOR="Red"]"[/COLOR], &Temp);[/CODE] The float format needs to be made a string with " " marks. | |
Re: >it should say that the user entered an invalid box number. but it stops scanning when the user enters a char variable. Actually, if the variable [B]n[/B] is initialized to or contain random data ( not initialized ) to something equal or bigger of 1 and equal or less than … | |
Re: [CODE]ptr=[COLOR="Red"](int *)[/COLOR]malloc(n*n*sizeof(int));[/CODE] Casting malloc is a residue practice from the times when the C programming language didn't support void type. It is best not to cast malloc since doing it can hide errors. [ICODE]#include <stdlib.h>[/ICODE] | |
Re: >And my earlier query of why [QUOTE]#define int float [/QUOTE] >is still not clear... You are substituting in your code, every word [B]int [/B]for the word [B]float[/B]. That's all. So, what happens when for example you write? [CODE]float main(void)[/CODE] It doesn't work properly, correct? Because main should return an int. | |
Re: [quote=WolfPack;394730] Actually humans started smoking because they ARE of superior intelligence.[/quote] And then the smoke got to our heads. | |
Re: >I wrote the solution in awk using substr() : [QUOTE] awk '{ if (substr($0,2,1) == substr($0,3,1)) print $0; }' emp.list[/QUOTE] A slightly different approach. Since the targets to compare are found always in the beginning, use only the first field. Separate individual characters using split and then compare. [CODE=awk]awk '{ … | |
Re: [QUOTE=PRATS 1990;831769]Whats the use of switch(ch) in c?[/QUOTE] This is an irritating question; classified in the section that says: if you can not make use of a search engine and make a simple research on it, you don't have any business learning how to program. | |
Re: >Writing programs for chess is too difficult and such complex calculations can be done practicallly only by supercomputers Darn! I knew that my Sony CLIE pda was a powerful machine, but I had no idea of its true supercomputer nature. ;) | |
Re: Assuming data format: [QUOTE]d15 509MB c1t0d0s5 d13 7.0GB c1t0d0s3 d11 1.5GB c1t0d0s1 d10 10GB c1t0d0s0 d25 509MB c1t1d0s5 d23 7.0GB c1t1d0s3 d21 1.5GB c1t1d0s1 d20 10GB c1t1d0s0[/QUOTE] For example purposes coming from datafile to awk and displaying to standard output. Modify to need. [CODE=awk]awk '/s/ { if ( index($2, "GB") … | |
Re: Is your keyboard broken? It looks like sticky key with (!), (,) and (?). Do you know that ALL caps represents YELLING! Not cool! Stop yelling at people you don't even know. Learn how to use a loop, and include the scanf() inside one. | |
Re: [QUOTE=Ancient Dragon;831115] [code] int spot = 0; int c; while( (c = fget[COLOR="Red"]s[/COLOR](fp) ) != EOF) { string[spot++] = c; } string[spot] = 0; // null-terminate the string [/code][/QUOTE] He really meant [ICODE]while((c = fget[COLOR="Red"]c[/COLOR](fp) != EOF)[/ICODE] And some further information. You really need to pass it a limit of … | |
Re: You came to the right place, but entered the forum with the wrong foot. I can notice a difference between the quality of writing of the first paragraph and the second paragraph. Which tells me you just copied and pasted your assignment. We don't give assignment completion away. Heck!, some … | |
Re: >Why the variable $number is losing its value outside while loop even though it's a global value? It has to do with the pipe Read [URL="http://nion.modprobe.de/blog/archives/531-Altering-a-variable-outside-the-scope-of-a-loop-influenced-by-a-subshell.html"]here[/URL] and you might know why | |
Re: Try this and see if you can figure out: [CODE=bash]echo "2.3 4.56789" | awk '{printf "%.2f %.2f\n", $1, $2}'[/CODE] | |
Re: The switch [B]-S[/B] is in the wrong part of the command. [CODE]gcc -S filename.c[/CODE] | |
Re: [QUOTE=deepugtm;817308]I use Turbo c ,How can I make that program,I use Windows Xp.[/QUOTE] Turbo C is not an adequate compiler for Windows XP. This is a helpful [URL="http://www.daniweb.com/forums/thread50370.html"]link[/URL] to modern compilers. | |
Re: [QUOTE=jenilgandhi;817306]hey i.e. int i=1; while (i<=60) { printf("#"); i++; } or do { printf("#"); i++; }while(i<60)[/QUOTE] Posted source code must be wrapped between proper tags that will display it in a consistent format and familiar neatness. Example shown [URL="http://www.daniweb.com/forums/thread93280.html"]here [/URL] | |
Re: Post the code you have done so far. Explain where you are having problems with. | |
Re: >True, what about if you're making a graph... and need to plot some x & y coordinates, what would be more readable? Since we are splitting hair, let's declare those [B]int[/B] variables outside those [B]for[/B] loops. Portability to the lowest common denominator should be a concern. | |
Re: >I found it and don't understand how to run it It runs in the command line and expects three arguments: The name of the program <space>the file name to be copy<space>the file name to be created as a copy. Mind that this is not a particular well written program. | |
Re: [URL="http://linux.wku.edu/~lamonml/algor/sort/index.html"]For the heck of it.[/URL] | |
Re: >(I think I'm over running an array but can't see where). [CODE]table[[COLOR="Red"]15[/COLOR]][1] = 0;[/CODE] To start, table can only be indexed to 14 >(anything at all!) There's not guarantee that malloc will allocate memory. You MUST check the return of that call. Where do you free the malloc()ed memory that … |
The End.