Answered Questions

  • Using C, How will you search for a word in file ?

    if i enter an ID Number it should look in the .txt file the employee who owns that ID Number then it will display it on the screen..

    Tanmay Hatkar

    • Oct 8th, 2019

    Can you please show me how to read a file until whitespace without using lib var type

    jbode

    • Sep 13th, 2017

    How is the file structured? Is it a text or binary file? Is it a flat file or a tree structure? Are the records fixed or variable length? Is there a delimiter between the ID and name? Are records in the file ordered by name or ID number?

  • C is not platform dependent.Why?

    we know that C is not platform independent.but if we make a program on a operating system and copy the same program on other os without any changes then this program will run after compiling and will give the same answer. so if same program will run on other os then why C is not platform independent.

    Ramesh Yadav

    • May 4th, 2012

    C is not platform dependent because it does not generate the uniform executables.
    suppose if we have build C code and generated binary in Windows and this same binary will not work on Linux.

    jbode

    • Oct 3rd, 2011

    It is true that *some* programs can be compiled on other systems without any changes and produce the same outputs. "Hello, World" should work everywhere with no changes. However, such trivially port...

  • Function to find Occurrences

    Write a function Occurrences() in a language of your choice that takes in two strings. The first is a search string, and the second is a sentence. For example, running the function:Running Occurrences ("o", "Red Gate Software - Ingeniously Simple Tools")will output: Occurrences of 'o': 4Occurrences ("at", "The cat sat on the mat")will output: Occurrences of 'at': 3charles.

    shashank

    • Nov 3rd, 2011

    Code
    1. void occ(char *x,char *y)
    2. {
    3.  char *a;
    4.  int r=0;
    5.  
    6.  while(a=strstr(y,x))
    7. {
    8.   r+=1;
    9.   y=a+1;
    10. }
    11. return r;
    12. }
    13.  
    14. void main()
    15. {
    16.  printf("occurances = %d",occ("at","the cat sat on the mat"));
    17. }

  • What is the difference between structure & union?

    how can we multiply this A*B without using "*" operator?

    Alejandro Visiedo

    • Mar 5th, 2016

    In an "union" type, all the members are mapped to the same base address, so that the size of the type is determinated by the biggest member. In a "structure" type, each member is mapped in sequence...

    Nitesh Raj

    • Apr 22nd, 2015

    Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members. In union, one block is...