I dont think I got it right but simply return the avg from the float mean() and display the result.
cout << mean(); //Like this ? :=)
I dont think I got it right but simply return the avg from the float mean() and display the result.
cout << mean(); //Like this ? :=)
Hello,
I really wonder that is it possible to open any file and play with the data inside it using C/C++ FILE pointer.
I'm taking a lecture called Data Management and File Structures and there we are working with text and binary files.
So I decided to research and work on binary files and try to open and edit them using standart i/o functions and classes. I'm now trying to create and play with a .bmp file. It goes well.
But I want to edit all the files in the system such as .mp3, .exe, .dat, .bin and database files ofcourse.
Is it possible? Can we treat these files as if they all are readable in binary mode? Where can i find any additional information?
Thanks..
I have a details view and SQL data source. In the details view i can fill the form and add the data to the database and then view this database in another page.
I have a "Date" row in the details view where must insert the date info. I want this to be automatically added to the database without requiring the users to enter them. I want to remove the date row and add the date info with "DateTime.Now" .
How can i do that?
Thanks.
You cant hold decimal values in integer type. Try float or double.
The most probable error would be pointer errors ofcourse. As the above message says you should print the list after every operation to check if the operation was successful.
If you send the error codes we may help better.
Maybe because of the limits of the integer type. Integers can hold numbers up to 32768 ( as i remember ). So any value greater than 2^16 will overflow and give you uncorrect results. You may try using double or a user created type to hold values for factorials as factorials can overgrow quickly.
I didnt get what you mean by function to pointer but let me explain something:
1- If you pass an arguement to a function without using pointer you pass it by value. In that function if you change the arguements value, when you get back from that function the value of the arguement will not change.
You cannot modify the value if you dont pass it as a pointer.
2-If you pass the arguement as pointer you may modify it if you want. If you pass arguements as pointers to a function it is called call by reference. You pass the adress of the variable and function knows the adress of the variable. So function is capable of changing the value of the variable of the specified adress.
If you want to master pointer( means if you want to program in C ) you may try char pointers to manipulate strings.
Pointers are hard, entertaining, dangerous and a must.
You may try adding up to lets say 100 and then divide all the values by 100 and assign them to the variables. Like;
a=25 b=30 c=40 d=5 adds up to 100.
var1=25/100
var2=30/100
....
If you get stuck post here again.
Kolay gelsin =)
Good job but if you dont have any questions you should send this thread to "Show off your projects".
You want to have a Graphical User Interface. Look for some GUI libraries for C.
The following code checks if the letter exist and occures less then 40 times. Maybe this is what you want ?
if( lettes[i] > 0 && letters[i] < 40 )
letters[i] = 1;
Ok, I got it know :)
You did the big part of the program then :) You just need to design a loop that runs for every alphabet( 26 times ). Then in it design another loop that prints alphabets. Inner loop must print the current alphabet as much as it's occurence.
If you got stuck let us know.
You must read the input once, in this case 15.000. Then use a loop to calculate the amount remaining. When the finalSum < 0 the loop terminates. The loop uses a counter representing the years, increases it every time the loop executes.
Then print the counter.
Not every program runs great on emulators. Try running it in a unix system.
You say that indexes of the array represents chars. Since indexes are unique there will be only one char for the corresponding index. How can there be 15 A where there is only one array[0] ?
And what those array elements are for? Where do you use them?
I didnt understand what your problem is. Please be more specific.
NP-complete is absolutely right.
Before you sit infront of the computer and start coding you'd better figure out what you really want to do and how would you solve the problem. Design an algorithm.
If you like programming and you believe that you will be good at it then I'd go for it.
A good programmer can learn about every aspects of a computer. For example a good programmer can become a web designer easily( I dont mean using PS or another design program, they have nothing to do with CS ).
I didnt understand what do you mean by network but you can be a network programmer too :)
You are very welcome :)
You can assign the value returned by the function "strlen(textStr)" so you avoid calling this function strlen*26 times :)
int a = strlen(textStr);
for(j = 0; j < a; j++) {
...
}
Maybe you should use binary files instead. This will decrease the encoding and decoding of the string that will be placed into the buffer, reducing the time your program consume dramatically.
Look at ASCII table and note the decimal values of chars you want to randomize. Then randomize values, then print them with using "%c" placeholder. For example;
char example = 97;
int exapmleinteger = 97;
printf("%c", example );
printf("%c", exampleinteger );
will both output 'a'.
Ofcourse it is possible, but if you want us to implement and send you the code that's not gonna happen.
Maybe you should send what you've got, then we may give you some ideas.
Ofcourse I cannot know what you used in the program, I look what you post here.
Your mistake is using floating numbers in a desicion statement.
Good project, good job. We need to know about the libraries used in the program to create an idea about alarm().
This must be an enjoyable project :)
mitrmkar catched really nice. The value is a bad pointer. You should check that value.
Please pay attention to your spelling when you are posting so we can follow easily.
Does the function ( read/write ) you first call in the program works and the following does not?
If so maybe you should do some procedure before attempting to do another work. I never programmed serial port before , it is just an idea :)
First if you want to dynamically enlarge the array you should use malloc and calloc, which dynamically reserves memory while the program is running.
If you want to insert values to an array, you should have the array element at the right side of the expression like "arr = something;".
You should reserve some space in the memory when you declare an array like "char arr[arraySize]" if you want to insert ( actually assign values to existing array elements ) values to the array.
main()
{
int i;
int arraySize = 10;
char myArray[ arraySize ] = {'a'};
for( i=1; i < arraySize; i++)
myArray[i] = ( char )i;
return;
}
You should avoid using float values in conditions.
The problem with your code is "scanf("%d", &n );". You are getting input in the form of integer so you are ignoring the fraction part of the input.
You should use "scanf("%f", &n);" to get a floating number.
In debug mode you can see what value is copied into char c, maybe you must clean the buffer before you take the character with scanf.
Some advice from me:
1-Use meaningful variable names, such as state, condition, myArray. It really helps you and us figure out what the problem is.
2-Learn and use coding standarts.
3-Learn debugging, it dramatically reduces the problems you encounter.
4-When asking a question you must use a good algorithm to tell the problem. Human can understand you better than computers but you still need to tell the problem in a meaningful way. :)
With inserting you mean manipulating a picture with C?
Actually with using C you can almost do anything. There are some tools to use for editing pictures using C.
BMP (bitmap) files can be edited bit by bit. You should check the following links:
http://en.wikipedia.org/wiki/BMP_file_format
http://www.vbforums.com/showthread.php?t=261522
A better aproach will be to divide the problem into several functions.
For example you can sort the id_numbers and then with an sort function, then you can printf the list with a print function, and you can eliminate the same records while printing the function.
Implementing such several loops in another another loop is kiliing the performance and the ease of implementation.
I dont understand the meaning of assigning 0 to sum in the for loop. If you would assign 0 to it why do you bother calculating it?
What are trees?
Wow, that kind of clarity triggered my heart attack.
If you see something dividing into two or more, there you have a tree. Trees are good. We all love trees.
Thanks for the links. I need some quality books to start. Any idea?
"printf("%d", p );" should print the adress of variable which p points to which is an integer.
If you dont assign any adress to the pointer then that pointer is bad ptr. You cant expect to get a meaningful value without assigning .
I've been developing console applications using C/C++. I now want to move on and create some GUI applications. For that i saw some libraries to create GUI. I think those libraries are OS dependent.
How can we create GUI applications compatible with Linux, Windows and Mac, or is it even possible.
If not possible, when we develop an application to run on Windows and we want to change it to run on Linux what portion of the application must be changed?
I want to hear some books about Linux C programming and GUI.
Thanks.
Thank you both. I got it now. :)
I got something. As we insert the leaf to for example root->left, we insert the new node but root still does not know the adress hence the pointer is still NULL. Is this the problem with my code?
As you said if we do it that way: "root->left = insert(root->left,item);" root now knows the adress of the new node. Am i right ? I am new to recursion and it seems a little complicated at first.
Thanks.
Oh you are right, i meant why does not the code work. But i dont seem to get why the code needs extra assignment like "root->left = insert(root->left,item);" .
It seems ok to me if i assign the newly created node to the root with:
if(root==NULL)
root = createNode(item);
I wonder why the following code work. In the debugger i see that every thing works fine but after the "root = createNode(item);" statement I can't see the new node assigned to root?
Node *insert( Node *root, int item )
{
if(root==NULL)
root = createNode(item);
if(root->data>item)
insert(root->left,item);
else if(root->data<item)
insert(root->right,item);
return root;
}
That is a good info. I will try it and see if it fits me better.
Thanks.
Narue is right of course. I gave the example so that he can see the exact situation.
Since I generally use binary trees it is a habit for me to declare the pointers seperately.
struct node
{
int data;
node *child1;
node *child2;
.
.
node *childm;
}
This is a very basic example. Then you must implement the addNode, traverseTree, searchTree
and other functions to use the structure. When implementing a tree you will need a lot of recursion or stack in order to traverse, search and to use other features that tree offers.
What do you want?
In button tag in the page add the following: onclick="1_click"
This will call the event handler 1_click() when the button is clicked.
@JasonHippy ;
Thanks for your comment. I have the Stack.cpp in the solution tree but your comment made me find my mistake X)
The mistake was that I did not add "myStack::" to the data members names in the Stack.cpp funcitons. Now i added "myStack::" to the begining of the data members and it works !
Thank you all .
Edit: Nice drum kit .
@Salem
Stack.cpp is included in the myStack.h header, but i tried including it in the main too, then it gave me the error "already included".
@MrSpigot
I tried what you said too but the errors remained.
Thank you both for your replies.
I mean if you comment the push and top there are no errors. I said they are linker errors in thread name.
Thanks anyway.
I am using VS 2008. The error happens when the balanced() function calls stack.push and stack.top. I dont know what is the problem so i posted the whole code.
I got some linker error, couldnt find the mistake. What is wrong?
#include "myStack.h" //Imports the Stack header file containing the declaration of the member functions
myStack::myStack()
/*The stack is initialized as empty */
{
count=0;
} //end of Stack::Stack constructor
Error_code myStack::push(const Stack_entry &item)
/*If the stack is full then the error code overflow is returned
else the item is pushed to the top of the stack and return error code success */
{
Error_code outcome=success; //default value of outcome is set to success
if(count>=maxstack) //the overflow condition is tested
outcome=overflow;
else //the success condition will be implemented
entry[count++]=item;
return outcome; //returns the Error_code type outcome
} //end of Stack::push function
Error_code myStack::pop()
/*If the stack is empty then return error code underflow and do nothing
else if the stack is not emtpy then pop the top of the stack */
{
Error_code outcome=success; //the default value of outcome is set to success
if(count==0) //stack is empty case is handled
outcome=underflow;
else //stack is not empty case is handled and pop is executed
count--;
return outcome;
} //end of Stack::pop function
Error_code myStack::top(Stack_entry &item) const
/*If the stack is empty then an error of underflow is returned.
Else if the stack is not empty then the top of the stack is assigned to the item */
{
Error_code outcome=success; //the default value of outcome is set to success
if(count==0) //the stack if empty case is handled and returned the underflow error code
outcome=underflow;
else /*the stack is not …
Thanks, lol I gave the extension .c as it was in the book. That will solve the problem i'm sure.