406 Posted Topics

Member Avatar for connormcleod

@gretty : Ancient Dragon is right its not efficient. The above code works right ??? Then whats the problem ? Why isn't this thread marked solved ?

Member Avatar for kvprajapati
0
9K
Member Avatar for adarshcu

After the end of file,the file is filled with null characters,so if you move the file pointer to a far off place and get a line from there then it inputs several '\0' characters into your string which when output by << doesn't show anything. NULL is a macro for …

Member Avatar for vmanes
0
101
Member Avatar for headacheinC

Well do you know what exactly you are doing or what you want to do ? [code=c] FILE *fopen(); // Why this ? [/code] And what are you expecting the computer to display when you are just opening the file and closing it ? [code=c] finput = fopen(pfile, "r"); if(finput==NULL) …

Member Avatar for headacheinC
0
136
Member Avatar for lukethedrifter

Don't pin in the whole code every time.Just extract the erroneous part,that way you too will [B]dive deeper into the code[/B] and easy for us to analyze too

Member Avatar for Ancient Dragon
0
226
Member Avatar for gretty

To check the length of file you have done [code=c] while(infile) { infile >> x; sequence_length++; } [/code] After this the file pointer is at the end of file now you need to re-assign the pointer to the start of file.So before taking array input do [code=c]infile.seekg(0,ios::beg);[/code] And then take …

Member Avatar for Ancient Dragon
0
93
Member Avatar for lexusdominus

[QUOTE=lexusdominus;884664]i want my program to pull out very specific small strings from files, but i dont know whats the best way of going about this. ive written a function that can get a specific line from a file, but its hard to keep track of where relevant data is. ive …

Member Avatar for csurfer
0
278
Member Avatar for JackDurden

It would be better if you divide that nary tree nodes in some hierarchical levels so that it would be helpful in deciding their positions in future.

Member Avatar for csurfer
0
123
Member Avatar for boiishuvo

[B][COLOR="Red"]Don't Shout !!![/COLOR][/B] Writing things in capital letters is regarded as shouting...! So don't use it. And it may be urgent for you not for us so have patience. And indent the codes and use [URL="http://www.daniweb.com/forums/announcement8-3.html"]code tags[/URL].

Member Avatar for VernonDozier
0
532
Member Avatar for cruisx

[B]Does no one read the forum rules ??? At least a glance ???[/B] Please go through [URL="http://www.daniweb.com/forums/announcement8-3.html"]this[/URL] once.[B]Use Code Tags[/B]. And [COLOR="Red"][B]Please Use English[/B][/COLOR] here.[B]This is not a mobile chat zone[/B]. Your mistakes : [code=c] cout<< (rand() % 10) + 1<< " "; //creates random numbers from 1 to 100 …

Member Avatar for VernonDozier
0
366
Member Avatar for 0xCMD

Hey its quite easy , 0x is hex right then ABC is calculated as follows : A * 16^2 + B * 16^1 + C * 16^0 i,e 10 * 484 + 11 * 16 + 12 * 1 2748

Member Avatar for csurfer
0
171
Member Avatar for san gabriel

Well the objective is just to compare two strings right? Then even though strcmp can do the work wouldn't the usage as [code=c] #include<string> using namespace std; //within main string str1 str2; //inputs to strings as cin<<string if(str1==str2)//comparision [/code] Wouldn't the above implementation be more efficient? As we are using …

Member Avatar for mirfan00
0
447
Member Avatar for lss123

Good work !!! But file access every time can be time taking,so,may be you can implement a sudoku board with linked list or a hash table so that traversal can get faster.

Member Avatar for lss123
0
475
Member Avatar for Peyton

This is one classical example of [URL="http://en.wikipedia.org/wiki/Recursion"]recursion[/URL]. I hope you know the rules of this problem. Here you have three stands say a b c where where n pegs are inserted into a from 1 to n numbering where 1 is on top and 2 below it 3 below 2 …

Member Avatar for csurfer
0
128
Member Avatar for catchmrbharath

Its better not to paste the questions given in other portals for [B]you to solve[/B] here for [B]us to solve[/B]. But since you have tried to code this is my view... >You are trying to find out factors of 2 and 5 for every number within a limit "num" for …

Member Avatar for Sky Diploma
0
145
Member Avatar for rajboy

[QUOTE]Qn 1. Write a C++ program that creates appropriate variables and performs the following actions: Gets the user to enter their name and year of birth. Adds the users names to one of two text files “wise.txt” or “strong.txt” based on their age at the start of this year. To …

Member Avatar for ithelp
0
100
Member Avatar for Traicey

Wow !!! asking source code in Dani directly and that too at two places. I am [B][COLOR="Red"]SHOCKED !!![/COLOR][/B]

Member Avatar for MosaicFuneral
0
152
Member Avatar for athlon32

Can I look at the module which generated this error I mean just that function.

Member Avatar for athlon32
0
121
Member Avatar for Nick Evan

Thanks for the threads ! It feels just like [B]coming back home[/B] where we actually started ! :)

Member Avatar for csurfer
4
352
Member Avatar for red999

Your program may be right and giving the right output too but try to use the inbuilt "C" functionality more.Because even after using recursion if you are doing so much work its nothing but "Crime Against Recursion".Try this... [code=c] #include<stdio.h> #include<string.h> #define MAXSIZE 10 void display(char c,int cnt,int i,char num[],int …

Member Avatar for JJS
0
80
Member Avatar for ankushbansal89

iamthwee is right but if the intention of your tutor is to make you try such things by using programming constructs then you may try using linked list to solve your problem.

Member Avatar for ankushbansal89
0
87
Member Avatar for san gabriel

Read Ancient Dragons post again. [QUOTE]Problems: the close parentheses is missing :-p[/QUOTE] You won't get the required output because strtok uses the character within " " in strtok(str," ") as the delimiter and uses it to cut the string rather than including it.This explains why the closing paranthesis is missing. …

Member Avatar for siddhant3s
0
168
Member Avatar for clutchkiller

Well your question is not quite clear but you can always use fopen command with : “rb” Open a binary file for reading “wb” Create a binary file for writing “ab” Append to a binary file “rb+“ Open a binary file for read/write “wb+“ Create a binary file for read/write …

Member Avatar for ArkM
0
146
Member Avatar for wislean

"Please don't kill the codes,Pay them some respect " After all,they are "your" codes: [code=c] for(i=0;i { tot[i]=0.40*Assignment_average[i]+ Quiz_Average[i]*0.15+ participation[i]*0.10+Midterm[i]*0.15+ final[i]*0.20 avr[i]=tot[i]*100; } [/code] Complete their format at least.... Errors: >Usage of "&menu" in printf is not only syntactically wrong but also useless.Why do you want to print value of …

Member Avatar for csurfer
0
164
Member Avatar for gplkrsna

You can create a new program for it where in you can declare a character array [code=c]char file[<file_size you want to set>];[/code] Read in the file into this array,so you are limiting the size of it,then delete the contents of the file and write the contents of the array back …

Member Avatar for csurfer
0
100
Member Avatar for jupkw

Try adding your TC path to the "path" ENVIRONMENTAL VARIABLE in system properties.More info given [URL="http://www.daniweb.com/forums/thread175434.html"]http://www.daniweb.com/forums/thread175434.html[/URL] look at this thread.

Member Avatar for vj4u99
0
256
Member Avatar for pdrino

Well I really couldn't get what you meant but I will answer to the point I think you asked...k Well you can allocate two dimensional array as follows: [code=c] char **array; //Your two dimensional array int str_nos=10; //No of strings you want to have int str_len=60; //Maximum length of each …

Member Avatar for Aia
1
2K
Member Avatar for sat4ever0606

[QUOTE=sat4ever0606;834501][B]For inserting a node at the beginning y the foll code wont work?[/B] [code] struct node { int data; struct node *-next; }*head,*run,*ptr; [/code][/QUOTE] Hey i think you missed out on the erreneous "-" sign behind next in [code=c]struct node *-next;[/code] It should be [code=c]struct node * next;[/code] And also …

Member Avatar for death_oclock
0
148
Member Avatar for amegahed3

Ancient Dragon has always got some great methods which come handy :) the above post by him is just superb. And ya if you want some predefined words as your file names for example in a business file like FINANCIAL, STRATEGIC and all you can feed it in the array …

Member Avatar for jephthah
0
100
Member Avatar for Dewey1040

This is where you went wrong. In your program pointers min and max are there but are not pointing to any memory space at all.So when you try to access some memory as *min or *max they try to refer a memory not been allocated hence segmentation fault core dumped. …

Member Avatar for Dewey1040
0
201
Member Avatar for Skorpion

Being in this community for a while you very well know our answer "You are in a hurry solve it yourself" So stop posting "do quickly" and all from next time because we are here to learn and not take orders... As for your answer choose any problem in which …

Member Avatar for csurfer
0
110
Member Avatar for jenilgandhi

Well there are several methods , but I would go with the simplest... Assume that you take the dimension of nxn martix as the input from the user where user feeds in value of n. And array[][] is the one in which he feeds in the value. Just have another …

Member Avatar for Aia
0
81
Member Avatar for meghs007

Well to solve this look a the matrix format... when we give an input the maximum number within the matrix is input square... that is if input is n then the maximum number feeded into the matrix will be n suqare. Assume : Array = a[][]; Input = n; sq …

Member Avatar for John A
1
83
Member Avatar for Ineedhelpplz

I think the conversation is loosing track. You want to write a C program to write main function,take input in array and then sort it through some sorting algorithm and then run search through your assembly program right? Concentrate on that.Do this first: 1)Writing a main program and taking inputs …

Member Avatar for csurfer
0
188
Member Avatar for csurfer

We know #define statements are executed before the program is compiled (preprocessor directives) and so the characters used should have no other meaning (say keywords),but still the following statement is not possible and is erroneous why ? [code=c]#define int float[/code] How many passes would the preprocessor directives run for as …

Member Avatar for csurfer
0
144
Member Avatar for Dewey1040

Here are some points which might help... 1)The program is perfectly alright and is running without any changes in it (In windows). 2)While running it through command prompt or in a shell it might cause some problems(may be i dont know) because of your argc and argv (why not just …

Member Avatar for uskok
0
118
Member Avatar for PRATS 1990

switch is used to SWITCH between things or choices. Both, the developers of C language and also the people on this forum are quite witty...so take their wise words and do some research on the topic first before posting a question...thats the only way to learn things in a programming …

Member Avatar for csurfer
0
116
Member Avatar for littlespy

What good would strstr do after you have tokenized the string??? Declare a string array and an integer array of some respectable size. Tokenize the string and assign every string formed to the indexes of string array.Now use the string array indexes and strcmp to find the repetition of a …

Member Avatar for nucleon
0
100
Member Avatar for sanushks

[quote]Also i would like to know, In Unix what are the cases in which C program encounters a segmentation fault/core dump?[/quote] I didn't get your earlier question but segmentation fault in UNIX mainly appears in cases of illegal memory access.I mean problem with your pointers.

Member Avatar for kenji
0
176
Member Avatar for miniroselit

[QUOTE=miniroselit;827384]whether there is c program implimentation forthe stable marriage problem? How can I extend this problem in a real life situation?[/QUOTE] Would you please state the problem please...

Member Avatar for ArkM
0
99
Member Avatar for RexxX

Whats the problem???Take a file pointer as FILE *fp; fp=fopen("<path>","<permission>"); //error check

Member Avatar for kenji
0
89
Member Avatar for jenilgandhi

[QUOTE=jenilgandhi;819041]plz help me to add two matrices using pointers..[/QUOTE] 1>Take two integer matrices say a[20],b[20],and a result matrix c[20],and two integer pointers pa and pb. 2>Assign the start address of arrays to these pointers. 3>Now if p points to a[0] then p+1 points to a[1] and you can even access …

Member Avatar for monkey_king
0
91
Member Avatar for moonw3ll

Make these changes in getData function: [code=c]int getData(int);[/code] change this to [code=c]int getData();[/code] ------------------------------------------------- [code=c]choice = getData(int);[/code] change this to [code=c]choice = getData();[/code] ------------------------------------------------- [code=c]int getData(int z) { z=0;[/code] change this to [code=c]int getData() { int z=0;[/code] ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- You cannot do this in menu function: [code=c]strcpy(theMenu[y].menuItem[LENGTH],{ " [1] Chicken …

Member Avatar for moonw3ll
0
156
Member Avatar for NRaf

Here you are declaring the array within the function and then returning it to the main. This kind of things always do create problems as the local variable is tried to destroy as soon as the control comes out of that function. So its better always to create the array …

Member Avatar for Narue
0
107
Member Avatar for jam123

Hey death_oclock is right. Not the other guy.Your question says details about many students so it should be of format: [code=c]student_name[<number of students>][<max length you would expect of a name>];[/code] And ya as per my suggestion you sincerely need to optimize your code.There are many redundant and waste lines too.Ex: …

Member Avatar for Alibeg
0
145
Member Avatar for vishy_85

>Naure I used devc++ with the proposed changes but it has some problem with the recognition of timeval struct itself,and also wit the usage of tv.tv_sec.Any suggestions with regard to usage and also the good compiler to use???

Member Avatar for Narue
0
100
Member Avatar for leebria

Assuming that you want to print out or store the 8bit hex values of each character of the input string I am giving these guidelines. Firstly take the input into an array by name str[30] may be. Let the final array be: unsigned char foo[30][30]; Now convert every one of …

Member Avatar for leebria
0
1K
Member Avatar for deepugtm

[QUOTE=deepugtm;816217]I want to write a program that can run a file in my hard disk.For example,a test.bmp file is there in location D:\home\test.bmp,that program should open(like double clicking on it ) that file (test.bmp) and i can view the image contained in the file.[/QUOTE] For bitmap images (or images in …

Member Avatar for csurfer
0
138
Member Avatar for fmylife

Hey assuming you want to sort your strings in order "smaller to larger" as you have been using the word "min" many times these are the things you need to do. 1>Correct every mistake nucleon has already stated. 2>Your selection sort function is a completely mess. You are comparing text[i] …

Member Avatar for csurfer
0
103
Member Avatar for chriscross86

Your program runs fine. Just make this small change and it will run. In your program it is: [code=c] for(k=1;k<=3;k++){ for(j=1;j<=5;j++){ for(i=1;i<=j;i++){ [/code] Change this thing as : [code=c] for(k=1;k<=3;k++){ for(j=1;j<=5;j+=2){ //Only change required... for(i=1;i<=j;i++){ [/code] In your code once a loop is finished the next set of runs for …

Member Avatar for srikanthkadem
0
88
Member Avatar for swetharvss

Well this is not very efficient method but as you are using nearly 80 arrays it might come handy. Just do this : [code=c] for(i=0;i<80;i++) for(j=0;j<80;j++) Temp_array[j] = Array[j][i]; [/code] In the above mentioned way you will move every element in first row to temporary array.And now apply some method …

Member Avatar for death_oclock
0
114

The End.