- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
47 Posted Topics
Hey guys, Is android an OS or firmware ? I understand that the firmware is programmed onto the hardware, and runs the OS. BIOS is Firmware, and Windows is OS. So, what's the firmware for Android OS ? What runs the Android code ? | |
Hey, Is there any difference between the 2 syntax, ie, str = "This is a test"; and strcpy(str,"This is a test"); I think, both of them, malloc some random 200 addresses, and give the starting location of the 200 chunk to the pointer variable 'ptr'. #include<stdio.h> char* str; int main(void) … | |
Hey, Is there a way to know the contents at address 6295600(say) in C ? I don't want to do using a pointer, that is, something like printf("%d",*p); int a = 5; p = &a; and address of a = 6295600. I want to be able to do something like, … | |
How do I print out the address a pointer is holding. Currently I'm using the code pasted below. But I'm getting this error. Error: t.c:13:2: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 2 has type ‘char *’ [-Wformat] Code: #include<stdio.h> #include<malloc.h> #include<string.h> #include<stdlib.h> char* str; int … | |
Please refer the code below I am trying to read integers from a file (till the end of file). But my problem is that only the last number is printed twice. /* fscanf example */ #include <stdio.h> int main () { int i; FILE * fp; fp = fopen ("/home/my/Desktop/write.txt","r"); … | |
A lot of people tell me that my code results in Memory Leaks. Since, I am still in an academic environment, it has not had any drastic result on any projects, but I still want to correct it. I have posted below some C code, please go through the coding … ![]() | |
Reading a character from the keyboard keeps giving me problem. When I do a gcc -o progname progname.c and ./progname, and press enter, it doesn't stop to receive the character. How can I correct this ? Code blocks are created by indenting at least 4 spaces ... and can span … | |
Re: use while((read = getline(&line, &len, fp)) != -1) | |
Why is it that this won't work instead of using atoi ? `Inline Code Example Here` #include<stdio.h> int main(void) { printf("%d",(int)"10"); return 0; } | |
Hey, how do you declare an array of strings using double pointer ? I normally use [CODE]char* str[] = {"this", "works", "fine" ,"for", "me"}; [/CODE] But I want to know if there is a way of declaring array of strings using something like [CODE]char** str; [/CODE] Please show me how … | |
Hi, I get the error "warning: array ‘str’ assumed to have one element [enabled by default]" when I am trying to fill in values inside the string array. [CODE]#include<stdio.h> #include<string.h> #include<malloc.h> char* str[]; int i = 0; int main(void) { for(i=0;i<5;i++) str[i] = (char*)malloc(200 * sizeof(char)); strcpy(str[0],"hello"); strcpy(str[1],"my"); strcpy(str[2],"name"); strcpy(str[3],"is"); … | |
Hi, I don't understand why we typecast malloc. For example, while creating a string/character array, we normally do, [CODE]line = (char*)malloc(200 * sizeof(char));[/CODE] assume we have already declared char* line; I was just reading the malloc man pages and it says that malloc allocates that much memory and returns a … | |
Hey , I wanted to know if browsing a page takes the same data as downloading it. Also, does streaming a youtube video take the same bandwidth as downloading it. The obvious answer would be yes, because buffering is basically downloading in itself. But I have noticed that it takes … | |
Hey, I have a problem taking input from the terminal. I need to read an integer first, then a string. But when I press enter after entering the integer, the string doesn't take any input. Yes, I did try using a fflush(stdin) between the 2 inputs, still doesn't work. I … | |
Hello people, I want to write a program which does the equivalent of going to google and searching for a word. So, for example, instead of going to google and typing out 'daniweb', I want to do that from a program. Does google offer any api's for that ? | |
Hey, I am doing my Final Year Project on NLP - something along IBM's Deep QA Project. [URL="http://en.wikipedia.org/wiki/Watson_(computer)"]http://en.wikipedia.org/wiki/Watson_(computer)[/URL] I would like to know what will be a good IDE to work on. My parameters for a good IDE in this project would be : 1)Good API's for Speech to Text … | |
Hey, is there a way to replace a single characters by 2 characters in a string ???? This was asked to me at 1 of the interviews. I answered linked list, I mean, take each node as a character, so u can easily insert 2 nodes, if u want to … | |
What is the number of swaps required to sort n elements using selection sort, in the worst case? The site i am referring says theta(n). Shouldnt it be theta(n2), cuz worst case it requires n swaps for each of the n elements. | |
Guys, ok after trying around stuff, I get that this is the way you initialize a structure in C. [CODE]#include<stdio.h> #include<conio.h> typedef struct s { int data; char gender; }st; st s1={5,'a'}; int main(void) { printf("%d "%c",s1.data,s1.gender); getch(); return 0; } [/CODE] But suppose i make a new instance of … | |
I have this really weird doubt in extern usage Consider the code [CODE] #include<stdio.h> int main(void) { extern int a; printf("%d",a); getch(); return 0; } int a=20;[/CODE] How is it that this code gives the output as 20 ??? My guess Since its an extern variable, it can be declared … | |
Guys , for this question, i have been able to come up with the O(n logn) - by sorting, and O(n.k) - by Tournament Principle algorithms, I read in a few places about Ordered Statistics but couldnt get anything out of it. Please can some1 give me an O(n) algo … | |
Guys, this is the code from KnR I dont understand this line nunits = (nbytes+sizeof(Header)-1)/sizeof(header) + 1; The entire code is as follows [CODE]static Header base; /* empty list to get started */ static Header *freep = NULL; /* start of free list */ /* malloc: general-purpose storage allocator */ … | |
I have 2 doubts 1)what is the default value of a mutex ? Is it 0 or 1? 2)Why cant we have a code like, this to solve the Concurrency issues. I mean, i know its not possible, but this was asked to me at an interview ... [CODE]if(pid == … | |
[CODE]union { int a; char b; char c[10]; }u1; void main() { int l=sizeof(u1); printf("%d",l); getch(); } [/CODE] This gives the output as 10, shouldnt it be 2 + 1 + 10 == 13 ??? Can some1 explain ? | |
hey, is there an optimized way to generate primes between 2 limits ? I was recently asked this question in an interview. Obviously, the Brute Force method would be to run a loop between the limits and check if each number has a factot between 2 and square-root of the … | |
guys, i am having trouble printing the LCS. This is the algorithm i am following to get the count of the LCS. [CODE]int main(void) { printf("\nThe LCS is %d",LCS(0,0)); } int LCS(int m, int n) { if(m==l1 || n==l2) return 0; if(X[m] == Y[n]) return 1 + LCS(X[m+1],Y[n+1]); else return … | |
In programming terms, Is there any difference between Generate Anagrams, and Generate Permutations of a string ???? | |
Hey is there a way to find the maximum occuring character in a string without using a hash map. ? Maybe in dynamic Programming or something ??? | |
1) Let X be the length of the first linked list until intersection point. Let Y be the length of the second linked list until the intersection point. Let Z be the length of the linked list from intersection point to End of the linked list including the intersection node. … | |
I am finding the recursion very difficult on this one. Could someone explain this to me. If this is a famous algorithm, a link containing the explanation would also do. I thought probably a couple of magic lines from you would change the way i am looking at this. I … | |
Hey, i was trying to implement the sqrt function in c, and this was what i came across, and it works abs fine. But i dont get this , is this a standard logic based on Taylor, Maclaurin or something ? Is this more of a programming question or a … | |
Hey, i found quite a few methods to [B]ADD TWO NUMBERS WITHOUT USING THE + OPERATOR[/B] , but this one is extremely weird. What does this printf statement mean ? What is %*d ????? [CODE]#include< iostream > using namespace std; int main() { int a,b,sum; scanf("%d",&a); scanf("%d",&b); sum=printf("%*d%*d",a,a,b,b); printf("\n"); printf("%d\n",sum); … | |
Hey, is there a function/call in c in windows to find the place from where your C-Development Environment is running. For example, (in case of Turbo-c), MOSTLY it is C:\TC\bin. Can i find this from within the program and output to a string or something ??? | |
Guys before i post my problem , lemme say that, i HAVE gone through the previous blogs/forums on daniweb, so please dont get annoyed with this topic again. But none of them answer my question My question is, "How do you write a structure to a file and retrieve data … | |
Hey, this one is agaain from File-handling How do you replace a word in a file with another word. The algorithm should be somewhat like this 1)Read (fgets) the entire line into a buffer. Locate the word/ position of the word. 2)From that point onwards, OVERWRITE the contents in the … | |
This one comes from file-handling. Say , i have a file of 95,000 lines. I have to analyse only those lines which start with a semi-colon. So my logic would be like, "Read first character of the line, if it IS a semi-colon, process it, otherwise jump to the next … | |
hi , getw() is used to read the next INTEGER from a filestream right ? Assume ------- My text document has the following 12 i am an 3 4 intern 5 67 Expected output --------------- Then , i expected that, on running getw() inside a while loop, it would print … | |
can u give me an example array of the best case of quick sort? I do understand that the best case of quick sort is when the elements are already in the pivot place., and that the complexity is O(n logn), but i m just not able to come up … | |
Guys, i have [b]2 doubts[/b] [b]Doubt-1[/b] -------- [code]int* p[10];[/code] Does it mean that 1)I have an array of 10 pointers, that means, each of them is capable of holding an address OR 2)I have a single pointer that points to an array holding 10 integers I too, feel , the … | |
Guys, can u tell me a good programming practice to stop iteration inside a for loop based on a condition, that is, something equivalent to a break in a while loop suppose i am iterating inside a for loop, looking for the first number divisible by 2, i would do … | |
guys, we use like a 2-d array very often. But what exactly is the use of a 2-d array ? Now when i look at it, i feel everything can be done using a 1-d array and incrementing the pointer appropriately. Is the only advantage of a 2-d array , … | |
Hello people, What exactly is a word ? I know a word is basically a unit and i know the word=2 bytes on an x-86 processor. But is the word size the same on an Itanium Processor as well ? I feel 1 word = 2bytes(x86) = 4bytes(32 bit system) … | |
I can write char a[] = "hello world"; , but i can not write char a[]; a = "hello world"; why is that ?? | |
Why do we have to initialize a pointer to a string when it is declared globally ? I mean , [B]This doesnt work[/B] [code=c] #include<stdio.h> #include<conio.h> char *str; int main(void) { gets(str); printf("%s",str); } [/code] [B]But this works[/B] [code=c] char *str="1"; int main(void) { gets(str); printf("%s",str); } [/code] Even upon … | |
Hello people, I am using Turbo-C Can anyone give me a sample program using the bool array I tried compiling the following code snippet. But it doesnt work. [code] #include<stdio.h> #include<conio.h> int main() { bool a[10]={true}; clrscr(); printf("\nHello World"); getch(); } [/code] It gives the error [B]Undefined Symbol bool[/B]. But … | |
what does int main() return and to what does it return That is, in the code snippet, [code] int main() { int a=0,b=5,c; clrscr(); c=a+b; return c; printf("%d",c); getch(); } [/code] 1)What is the expected output ? 2)I tried compiling this and i dont get anything on the screen 3)In … | |
i have a doubt. why cannot we use clrscr() before initializing a variable in C? i mean, why wont this work ? void main() { clrscr(); int a,b; ---- ---- getch(); } It'll give an error saying , "Declaration is not allowed here " Logically speaking , you should be … |
The End.