I have written a simple C function to convert a string to an integer.
char* inttostr(int num)
{
char buf[10];
int i = 0;
int j = 0;
Type: Posts; User: lazyme
I have written a simple C function to convert a string to an integer.
char* inttostr(int num)
{
char buf[10];
int i = 0;
int j = 0;
Ok thanks this works. I assumed that since I had brackets around the post-incr and post-decr operators, it would happen before the recursive call.
Thanks again anduril462 and itsme86
I wrote a recursive function to find if a given string is a palindrome
#include <stdio.h>
int isPalindromeRec(char *start, char* end);
int main()
{
char str[] = "abccba";
I am aware of the CreateProcess use to launch a new process. I want to know if I could use it in a situation like this
1. I want to launch the windows command prompt(cmd.exe) and run a batch file...
Hi ,
I have written a piece of code to reverse a sentence by reversing individual words at a time..
I have tried it and it works fine.
#include <stdio.h>
#include <string.h>
void...
The delete works fine now for every node other than the last node in the tree. Even for the last node, the node is deleted however the memory pointed to by the rootNode struct is freed.
For the...
^^
Thanks for pointing out the mistake. The delete works just fine now.
else if( (*nodeToDelete)->leftChild == NULL )
{
tempNode = (*nodeToDelete)->rightChild;
(*nodeToDelete)->data =...
I found there was an error with my relinking and the nodes with one children were not getting relinked at all.
I managed to fix some bugs and the delete works fine now for nodes with 1 child and 2...
I need help with the delete operation on a binary search tree. The delete operation works fine for leaf nodes and nodes with one child. However, it does not work fine with nodes with 2 childs.
...
@claudiu and Adak - Thanks. I will look into it.
@brewbuck - My array width and height are both always in powers of two. What is the bit manipulation trick I can use?
Thanks
^^
I will take care of the printfs and the variable names. I used the printfs just for debugging and would not be a part of my final code.
I cannot hard code the order array as my final code wont...
I want to traverse a matrix in zig-zag fashion.
Say my matrix is
a11 a12 a13 a14
a21 a22 a23 a24
a31 a32 a33 a34
a41 a42 a43 a44
Ok. That works.
Thanks
I wrote a simple program to reverse a string in C.
I am getting an exception on running it. Heres my code
#include<stdio.h>
#include<string.h>
void reverse(char*);
I have written a simple code to practice some basics of c++ and some file handling. Haven't really used any of the OOP features. The program should open the input file and read each individual number...
Ok.
What do you suggest me to change? Is my for loop flawed?
This is the best way I could think of implementing it.
Turns out there was no problem with the code. I was doing addToQueue(time4) twice hence the problem :|
Sorry MK27 my stupid goof up wasted your time.
I am just trying to test my addToQueue function by passing time values in random order.
I agree that I can get the same timestamp in two successive calls and will have to handle it. Thanks for the...
Hi,
I am trying to implement a priority queue of unsigned ints(timestamps) using array.
Here is what my code looks like.
The GetCurrTime returns time in microseconds
unsigned int...
I want to learn OS programming in C++ and found by searching the forums that Nachos is the best place to start.
I am looking for resources that would help me get started quickly. Anyone knows a...
Here's one way to swap 2 integer variables a and b.
a= a+b
b= a-b
a= a-b
Thanks anon. You have helped me optimize my code quite a lot and it looks much better now.
Thanks anon. I have written my code around this and it works fine. The structure contains 13 elements now.
I am posting my complete code below. Please let me know if you can foresee any...
I want set_difference to determine the items are same only if all the four fields match.
Can I achieve this with
bool operator< (const ps_report_rows& lhv, const ps_report_rows& rhv)
{
...
No, I don't have the operator < defined.
I dont necessarily need to compare more than one field in the struct. Can I use set_difference if my lists are sorted by any field in the struct?