what is a use flag() function in c language?
540580
It is actually used to give a specific address of a variable to be called..
92611
Use the following syntaxis:\n\nLike *[#]*
881644
Something like this:\n\nint **myArray;\nint s1,s2,i;\n\nprintf("Input row size: ");\nscanf("%d",&s1);\nprintf("Input column size: ");\nscanf("%d",&s2);\n\nmyArray[0] = malloc(s1*s2*sizeof(int));\nif (myArray[0] != NULL ) {\n  for (i = 0;i<s1,i++) {\n         myArray[i] = (i * s2) + myArray[0];\n  }\n}\n\nmyArray can then be used as normal\n\nmyArray[2][4] = 20;
923185
int main(int argc, char *argv[])\n{\nint c, i, j, k, l, m;\nshort will_continue = FALSE;\nunsigned char index_buffer[BUFFER_LENGTH];\nunsigned char line[BUFFER_LENGTH];\nchar *p[2];\nunsigned char code[MAX_CODE_SIZE] = "";\nunsigned char code_word[MAX_CODE_SIZE] = "";\nint current_dic_fill = 2;\nFILE *fd, *code_file;\nunsigned char dictionary[DICTIONARY_SIZE][MAX_WORD_LENGTH];\nunsigned char word[MAX_WORD_LENGTH];\n\nif(argc != 3) { /* We require two arguments */\nprintf("Welcome to the Lempel-Ziv encoder.&#92;n This program encodes a data file with the lempel-ziv algorithm. &#92;nPlease enter two arguments; the first is the data input file, the second is the encoded output file.&#92;n");\nexit(0);\n}\n\n/* Open the input file */\nfd = fopen(argv[1], "r");\nif (fd == NULL) {\nprintf("Could not open the file name: %s , exiting!&#92;n", argv[1]);\nexit(-1);\n}\n\n/* Map the first two characters of the input to the dictionary */ \ndictionary[0][0] = fgetc(fd);\ndictionary[0][1] = '&#92;0';\ndictionary[1][0] = fgetc(fd);\ndictionary[1][1] = '&#92;0';\nif ((fseek(fd, -2, SEEK_CUR)) < 0) /* Reset the file cursor */ \nexit(-1); \n \nwhile ((c = fgetc(fd)) != EOF) { /* Main file reading loop, reading character by character */\nif (strlen(word) >= MAX_WORD_LENGTH) {\nprintf("Current word: %s is to big to handle, bailing out!&#92;n", word);\nexit(-1);\n}\n\nword[strlen(word)] = c;/* Append the newly read character to the end of the current word */\nword[strlen(word) + 1] = '&#92;0';/* Dont forget the null termination */\nfor (i = 0; (i < current_dic_fill) && (!will_continue); i++) {/* Slow linear search through the dictionary */\nunsigned char current_dict_word[MAX_WORD_LENGTH];\nfor (j = 0; dictionary[i][j] != '&#92;0'; j++) {\ncurrent_dict_word[j+1] = '&#92;0';/* Dont forget the null termination */\ncurrent_dict_word[j] = dictionary[i][j];\n}\nif (strcmp(current_dict_word, word) == 0)  /* Found a match in the dictionary*/\nwill_continue = TRUE; /* Flag so that we break out of the double loop */\n}\nif (will_continue) {\nwill_continue = FALSE;\ncontinue;\n}\n\n/* Didn't find a match, save the word on the first available place in the dictionary */\ncurrent_dic_fill++;\nif(current_dic_fill > DICTIONARY_SIZE) {\nprintf("Dictionary full, exiting!&#92;n");\nexit(-1);\n}\n\nfor (i = 0; i < strlen(word); i++) \ndictionary[current_dic_fill - 1][i] = word[i];/* Save the word in the dictionary */\ndictionary[current_dic_fill - 1][strlen(word)] = '&#92;0';/* Don't forget to null terminate the string */\n\n/* Remove the last caracter and save the dictionary index as code*/\nstrcpy(code_word, word);\ncode_word[strlen(word)-1] = '&#92;0'; /* Remove the last character from the word to be coded */\nfor (i = 0; (i < current_dic_fill) && (!will_continue); i++) {\n/* Another slow linear search through the dictionary */\nunsigned char current_dict_word[MAX_WORD_LENGTH];\nfor (j = 0; dictionary[i][j] != '&#92;0'; j++) {\ncurrent_dict_word[j] = dictionary[i][j];\ncurrent_dict_word[j+1] = '&#92;0';/* Dont forget the null termination */\n}\nif (strcmp(current_dict_word, code_word) == 0) {/* Found a match */\n/* As we in this inefficient implementation are saving everything in a plain text file we need to convert the int to a string. I later found out that you can solve this one much easier with a simple sprintf call :/ */\nl = i;\nk = 0;\ndo { /* Count the amount of digits */\nif((l % 10) == 0) \nl++;\nl = l / 10;\nk++;\n} while (l !=0);\nif (k > 1) { /* Slow path for all index numbers bigger than 9 */\nfor(l=0; l < k; l++) {\nindex_buffer[l+1] = '&#92;0';\n\nindex_buffer[l] = i / pow(10, k-l-1);\nif (l == 0) {\nindex_buffer[l] += '0'; \ncontinue;\n}\n/* For each numeral except the first one (i. e 1xx), subtract the higher numerals */\n/* example: 123, we want the number 3
706549
Try to read the common inside the code.(inside the "/*.... */")\n\nThis function do couple of things:\n1. It is to check the input command.\n2. Set the parent thread to wait. \n3. Create a child thread.\n4. Use the child thread to run the command.
158838
I believe that modulo "%" is an integer operator. For floating point numbers, you should use the function "fmod", which is a standard function whose prototype is in math.h.\n\nFloating point is useful for a number of things, typically:\n\n- where fractional information is required (although using fixed point arithmetic can suffice here too)\n\n- where overflow is possible, such as if your long is only 32 bits, and your result may be larger than 2^31 - 1\n\nThe float *should* work - perhaps there is a problem with your declaration, or even possibly your compiler (sometimes happens). It is frustrating learning how to program in C and takes quite a while to master - that is why I always laugh at the "Learn C in 24 hours" books.
702462
I would have to see the code.\n\nMove the fopen before the while and the fprintf before the curly braces.  Leave the fclose after the curly braces.\n\nFopen\nwhile {\n\nfprintf ;\n}\nfclose
614947
#include <iostream.h>\n#include <conio.h>\n#include <process.h>\n\nmain()\n\n{\n\nchar c;\n\nclrscr();\ncout<<"Press 0 to exit&#92;n";\n\ndo\n{\n\n c=getch();\n\n switch(c)\n {\n   case '0': exit(0);\n   case '1': cout<<"I";break;\n   case '2': cout<<"L";break;\n   case '3': cout<<"o";break;\n   case '4': cout<<"v";break;\n   case '5': cout<<"e";break;\n   case '6': cout<<"U";break;\n }\n\n} while (1);\nreturn 0;\n}
935645
main() { static char *a="n0body"; char b[512],*c,*d;\n  while (c=gets(a)) for (d=a;c;*c^=*d,c++,d=*++d?d:a);\n  printf ("%s&#92;n",b);}\n\n\nhappy?
756121
#include <iostream>\n\nusing namespace std;\n\nchar *yourUsercode = "user";\nchar *yourPasscode = "pass";\n\nint main()\n{\n   string usercode;\n   string passcode;\n\n   cout << "LOGIN:&#92;n&#92;n";\n   cout << "USERCODE:&#92;n";\n   cin >> usercode;\n\n   cout << "&#92;nPASSCODE:&#92;n";\n   cin >> passcode;\n\n   if (usercode == yourUsercode){\n\n      if (passcode == yourPasscode) {\n         cout << "Access Granted&#92;n";\n      } else {\n         cout << "Invalid Passcode&#92;n";\n      }\n\n   } else {\n\n      if (passcode == yourPasscode) {\n         cout << "Invalid Usercode&#92;n";\n      } else {\n         cout << "Access Denied&#92;n";\n      }\n\n   }\n   \n   return 0;\n}
116319
In C, "void" has three distinct uses.\n\n1) Return values for functions. If a function returns literally NOTHING, then it is declared as returning void. This tells the compiler not to push/pop any return value on/off the stack on return. It also tells the compiler that the result of the function cannot be assigned or compared to any variable.\n\n2) Generic pointers. When you are dealing with generic pointers, such as returns from "malloc", parameters to "free", "memcpy" and such, these functions need pointers, but they really don't care what data type the pointers actually point to. Rather than declaring a copy of these functions that returns every possible atomic type (char, short, int, long, float, double and such), they simply use a pointer to type void (void*) instead.\n\n3) Ignoring return values. If you are using a particularly picky compiler, or even a program such as Lint that produces warnings when you ignore the return value of a function that returns something other than void, you can cast the function call to type void to make the warning go away if you really don't need to know the return value.\n\nFor instance, "printf" returns an "int" value. So if you use the following line in your program:\n\nprintf ("Hello world");\n\nit could actually generate a warning, since you ignore the return value. If instead you use the line\n\n(void) printf ("Hello world");\n\nyou are telling the compiler that you are purposefully ignoring the return value, so it will not issue a warning in this case. This is of particular use if you have a policy of zero warnings (as all programmers should).\n\n"Void" kind of lives in limbo just outside of datatypes - it is not a modifier such as "static", "const" or "volatile", but it is not possible to declare a variable of type "void". It is kind of in its own little world there.
195727
Here is one way of doing it, using only what we've seen so far: \n\n#include <stdio.h>\n\nextern int getline(char [], int);\nextern int reverse(char [], int);\n\nint main()\n{\nchar line[100];\nint len;\n\nwhile((len = getline(line, 100)) != EOF)\n{\nreverse(line, len);\nprintf("%s&#92;n", line);\n}\n\nreturn 0;\n}\n\nint reverse(char string[], int len)\n{\nint i;\nchar tmp;\nfor(i = 0; i < len / 2; i = i + 1)\n{\ntmp = string[i];\nstring[i] = string[len - i - 1];\nstring[len - i - 1] = tmp;\n}\nreturn 0;\n}\n\nIn practice, it would be a nuisance to have to pass the length of the string to the reverse function. Strings in C are always terminated by the ``zero'' or ``nul'' character, represented by &#92;0. Therefore, reverse (or any piece of code) can always compute the length of a string, either by searching for the &#92;0, or by calling the library function strlen, which computes the length of a string by searching for the &#92;0. Here is how the program might look if the reverse function did not require that the length of the string be passed in: \n#include <stdio.h>\n#include <string.h>\n\nextern int getline(char [], int);\nextern int reverse(char []);\n\nint main()\n{\nchar line[100];\n\nwhile(getline(line, 100) != EOF)\n{\nreverse(line);\nprintf("%s&#92;n", line);\n}\n\nreturn 0;\n}\n\nint reverse(char string[])\n{\nint len = strlen(string);\nint i;\nchar tmp;\nfor(i = 0; i < len / 2; i = i + 1)\n{\ntmp = string[i];\nstring[i] = string[len - i - 1];\nstring[len - i - 1] = tmp;\n}\nreturn 0;\n}
979933
I'm giving u the program (in C), just go through it, then write the algo. It'll be easier.\n\n// Program :  MERGE  SORT\n\n#include<stdio.h>\n#include<conio.h>\n\nvoid mergesort(int *,int);\n\nvoid main()\n{\nint x[30],n,i;\nclrscr();\nprintf("Enter total no. of elements");\nscanf("%d",&n);\nprintf("Enter %d nos.",n);\nfor(i=0;i<n;i++)\n   scanf("%d",&x[i]);\n\nmergesort(x,n);\n\nprintf("After sorting in descending order :&#92;n");\nfor(i=n-1;i>=0;i--)\n  printf(" %d",x[i]);\n\ngetch();\n}\n\n\n\nvoid mergesort(int x[],int n)\n{\n  int aux[30],l1,l2,u1,u2,i,j,k,size;\n  size=1;   // merges file of size 1\n  while(size<n)\n  {\n    l1=0;   // initialize lower-bound of 1st. file\n    k=0;    // k is index for auxilliary array\n    while(l1+size<n)\n    {\n      // initialize remaining parameters...\n      l2=l1+size;\n      u1=l2-1;\n      u2=(l2+size-1)<n ? (l2+size-1):(n-1);\n      for(i=l1,j=l2;i<=u1 && j<=u2;k++)\n if(x[i]<=x[j])\n   aux[k]=x[i++];\n else\n   aux[k]=x[j++];\n      while(i<=u1)\n      aux[k++]=x[i++];\n      while(j<=u2)\n      aux[k++]=x[j++];\n\n      l1=u2+1;\n    } /* end of 2nd. while-loop */\n    for(i=l1;k<n;i++)\n       aux[k++]=x[i];\n    for(i=0;i<n;i++)\n       x[i]=aux[i];\n\n    size*=2;\n  } /* end of 1st. while-loop */\n}
169151
int\nmain (void)\n{\nfor(i=0;i<10;i++){\nprintf("some thing output here %d", i)\n}\n}
195373
Try this:\n\n#include <stdio.h>\n\nmain()\n{\nint size,array[50],n,m,border,max,buf,step;\nint i, j, temp;\n\nprintf("Input number of elements in array:");\nscanf("%d",&size);\n\nfor(n=0;n<size;n++) {\n  printf("input %d. element of array:",n+1);\n  scanf("%d",&array[n]);\n  }\n\n for (i=(size-1);i>=0; i--)\n  {\n   for(j=1;j<=i;j++)\n    {\n     if(array[j-1]>array[j])\n      {\n       temp=array[j-1];\n       array[j-1]=array[j];\n       array[j]=temp;\n      }\n     }\n   }\n\nfor(n=0;n<size;n++)\n   printf("%d. element: %d&#92;n",n+1,array[n]);\n\n}\n\n\n\nHERE IS MY OUTPUT:\n\nInput number of elements in array:8\ninput 1. element of array:6\ninput 2. element of array:2\ninput 3. element of array:3\ninput 4. element of array:5\ninput 5. element of array:1\ninput 6. element of array:4\ninput 7. element of array:5\ninput 8. element of array:7\n1. element: 1\n2. element: 2\n3. element: 3\n4. element: 4\n5. element: 5\n6. element: 5\n7. element: 6\n8. element: 7
345718
int main (void)\n{\nint a,rem\ncout<<"enter the number";\n<<cin a;\nrem=a/a;\nif(rem>0)\ncout<<"its integer";\nelse\ncout<<"not a integer";\nreturn 0;\n}
680504
/*\nOriginal Question:\nI am writing a C program in Solaris environment...if i\nwant to execute some system command i can do it using\nsystem("string to be executed")....but it accepts string\nonly. what if i want to pass some variables to system at\nrun time....suppose i was to use this commands at runtime\n"cat file1 file2 >file3"....how i wud pass the file names?\nany suggestions !  thnx in advance Amardeep Sidhu\n*/\n\n#include <stdlib.h>\n#include <stdio.h>\n\nint\nmain(int argc, char* argv[])\n{\n\n  /* First, get some values into variables */\n\n  char *str1 = "ls";\n  char *str2 = "-l";\n  char *str3 = "/tmp";\n\n  /* One common trick to using "system()" is */\n  /* to "sprintf()" the arguments into a buffer */\n  {\n    char buffer[100];\n    sprintf(buffer, "%s %s %s", str1, str2, str3);\n    system(buffer);\n  }\n\n  return 0;\n}