Monday, May 24, 2010

Help in c language.data structure ?

hi...we need to create a linked list of structures(nodes) using pointers ..the problem when i allocate a place for every new node it gives an error :





#include%26lt;stdio.h%26gt;





struct node{


char name[20];


struct node *next;


};





int main(void){





struct node *p;


//we want to create 3 nodes





for(int i=0;i%26lt;3;i++)


{





p = new node; //AND HERE IT GIVES THE ERROR ('new' undeclared identifier)





so whats the problem ?any help is appreciated

Help in c language.data structure ?
Change the struct as follows:


#define NAME_SIZE 20





struct node{


char name[NAME_SIZE];


struct node *next;


};





int main(void){





struct node *top = NULL;


struct node *newnode;


//we want to create 3 nodes


char buf[256];





for(int i=0;i%26lt;3;i++)


{


newnode = makeNode();


sprintf(buf, "Node # %d", i); /* make a node name */


setName(newnode, buf);





if ( top != NULL) newnode-%26gt;next = top;


top = newnode;





}


}


/* create a function make a node */


struct node * makeNode()


{


p = (node*)malloc(sizeof(node));


/* remember to initialize the node name */


p-%26gt;name[0] = '\0';


p-%26gt;next = NULL;


return p;


}


/* create a function to set the name


* this makes sure that you dont put in a string


* that is too long and overwrite memory.


*/


void setName(struct node * p, char * name)


{


strncpy(p-%26gt;name, name, NAME_SIZE);


/* null terminate the string */


p-%26gt;name[NAME_SIZE-1] = '\0';


}
Reply:"new" is a C++ operator, use malloc for C:





p = (node*)malloc(sizeof(node));
Reply:I think in c you need to do something like:


p = (node*)malloc(sizeof(node));





instead of p = new node;





you may want to check if your struct format is correct as well

survey software

In C++, What is the use of using std::ios? What will it do in the program?

I also want to know the use of


using std::setiosflags


and


using std::fixed


Can u give examples for all


Explain pointers in simple and complete way...


Can u explain how to use strings...especially when the


program is in class format?


Thanks

In C++, What is the use of using std::ios? What will it do in the program?
Please do your school questions alone otherwise you will not learn. I am sure that your C++ book explains all these if only you did care to read it.
Reply:.... "and then, could you write a research paper for me on the rise of computing in the 20th century. Also, explain, in mind-boggling detail, the entire concept of object oriented programming. Can u give an exhaustive explanation of all the different data types, as well as complete programs that use them....."


Ok - I'm on it!
Reply:Even worse Old Programmers like me will never hire you.


In c++, how would u delete a node from a linked list?

ok so im supposed to delete a user specified node from a list of 10 nodes. I can locate the node but how would i actually delete it? I like dymanic arrays but sometimes r a pain cause of pointers :(

In c++, how would u delete a node from a linked list?
In general you will





1. Point the previous node at the next node


2. If it's a doubly linked list point the next node at the previous node


3. Destroy the current node, being sure to delete and release all allocated memory.





This site provides more detail:


http://www.inversereality.org/tutorials/...


C++ programming help?

Write a program that uses a random number generator to create sentences. The program should use four arrays of pointers to char called article[], noun[], verb[], and preposition[]. The program should create a sentence by selecting a word at random from each of the arrays in the following order: article[], noun[], verb[], preposition[], article[], noun[]. As each word is picked, it should be concatenated to the previous words in an array which is large enough to hold the entire sentence. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end with a period.





The arrays should be filled as follows: article[] should contain "the", "a", "one", "some", and "any"; noun[] should contain "boy", "girl", "dog", "town", and "car"; verb[] should contain "drove", "jumped", "ran", "walked", and "skipped"; and preposition[] should contain "to", "from", "over", "under", and "on".





i just need started

C++ programming help?
gr8 question dude,but y do u thnk dat someones going to waste so much time and energy doing dat.u shud consult some professional guy ,here


Need help with a turbo C program?

Well you see I am trying to make a program with pointers in which it counts the number of occurrences of any two vowels in succession in a line of text by using pointers.For example


"Please read this application and give me gratuity". Such occurences are ea,ea,ui.


And in case anyone knows from where this program has been taken,please do tell:)

Need help with a turbo C program?
You didn't explain whether u wanted 'aaee' to be counted as 2 or 3. I assume it to be 3 as aa,ae,ee. The code assuming this is:








#include%26lt;stdio.h%26gt;


#include%26lt;string.h%26gt;


int isVowel(char a)


{


if(a%26gt;64%26amp;%26amp;a%26lt;91)


a+=32;


if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u...


return 1;


else return 0;


}


int main()


{


char *a="Please read this application and give me gratuity";


int i=0, count=0;


while(a[i+1]!='\0')


{


if(isVowel(a[i])%26amp;%26amp;isVowel(a[i+1]))


{printf("Occurence no %d: %c%c",i+1,a[i],a[i+1]);


count++;}


i++;


}


printf("The desired count is %d", count);


return 0;


}
Reply:if you dont like programming and would rather cheat than even attempt it, drop the class or get a new major like English Lit :)
Reply:Please look at the comments. Try to follow the logic. Plug in a sample word or phrase. Notice how the program processes the input at each stage of its execution.





Note: Below, I did not know whether you want a user to input a string, or just program so that the line of text is directly assigned to a pointer:





char * copy_str = "Please read this application and give me gratuity"





I allowed for user input of text, which I assigned to a character array. I subsequently copied that array into a character pointer—for further processing.





If you wish, you can replace all code located between the two lines of asteriks (*'s) with the above * copy_str assignment statement. Simply place the assignment immediately above the While clause.


___________________________





#include %26lt;stdio.h%26gt;


#include %26lt;string.h%26gt;


int main()


{


int i;


int count = 0;


int singleVowel = 0;





/*************************************...


/* 50 is space enough for text and terminating character. */


char buffer[50];





printf("Enter a line of text: ");


fgets(buffer, sizeof(buffer), stdin);





/* Copy input into a character pointer for further processing. */


/* First, allocate memory; and, then do the copying. */


char * copy_str = malloc( strlen(buffer) + 1);


strcpy(copy_str, buffer);


/*************************************...





/* Now, lets iterate through each character in the string. */


while (*copy_str++ != '\0')


{


switch(*copy_str)


{


/* Check for a vowel. */


case 'a': case 'e': case 'i': case 'o': case 'u':


case 'A': case 'E': case 'I': case 'O': case 'U':


/* We have found a vowel; */


/* so, check to see if the preceding character was a vowel */


if (singleVowel = =1)


/* Increase the count of consecutive vowels */


count++;


else


/* Here, the preceding character was not a vowel */


/* If the next character is a vowel, */


/* then it will counts as being a consecutive vowel. */


singleVowel = 1;


default:


/* This particular character is not a vowel. */


/* So, any next vowel will not be a consecutive one */


singleVowel = 0;


}


}


printf("In text, we have %d consecutive vowels.\n", count);


return 0;


}





________________________

survey research

C programming?

pointers,functions,characters

C programming?
Yes!
Reply:http://www.physics.drexel.edu/courses/Co...





More advanced


http://www.augustcouncil.com/~tgibson/tu...





Remember, variables contained as pointers don't contain data, just reference the memory of another variable





so if


int a = 3;


int *b = %26amp;a


*b = 7


then a =7
Reply:What is the question?!?





I am a C++ programmer and know some things about C. But you do not have a question!
Reply:Ok, I'll play.





pointer = variable designed to hold an address where the data "lives" in memory = be careful to initialize or go directly into la-la-RAM





functions = statements grouped together to be reused or 'called' many times = more efficient coding





char = character = smallest allocated storage unit


C programming!!!help!!!?

i cant understand clearly the uses of pointers arrays...what are macros??the preprocessor statements??





please briefly explain these to me...or give me some very USEFUL links....





thank you very much!!

C programming!!!help!!!?
Hint: google.com is very useful.





Macros: http://gcc.gnu.org/onlinedocs/cpp/Macros... %26gt;%26gt; found with "C Macros"


Preprocessor: http://gcc.gnu.org/onlinedocs/cpp/ %26gt;%26gt; found with "C Preprocessor"


Pointers and Arrays: http://c-faq.com/ %26gt;%26gt; I know this one but Google will get it for you as it is ridiculously popular and well known
Reply:pointer-it is a variable which stores the address of the that variable to which it points.


for eg-int*j


j=%26amp;a;


now when you print j it wiil show you the address of a


and when you print *j it will show you the value of a.





arrays -the are used to store various values of same data type under common variable name.





macro-you can type a name in a program and define it above void main.during compilation where ever the name ccurs the definition is placed tis is macro.





what i would suggest you isif u live in india then you buy yashavant kanetkar(let us c) if you are a bigenner.





if you want to form strong basis in pointers you should go for-


pointers in c(yashavant kanetkar).it is a thin book.





the books r written in easy language.


90% computer studying college students(Indian) recommend this book for beginners.


C++ Programming check two vectors, same elements?

I'm having some serious issues with a programming question:





Write a predicate function





bool same_set(vector%26lt;int%26gt; a, vector%26lt;int%26gt; b)





that checks whether two vectors have the same elements in some order, ignoring multiplicities.





For example, the two vectors





1 4 9 16 9 7 4 9 11





and





11 11 7 9 16 4 1





would be considered identical.





It also states that I will probably need to use one or more helper functions for this programming.





If someone could help me solve this, even just some helpful pointers, it would be much appreciated. Thankyou.

C++ Programming check two vectors, same elements?
Because this is obviously a homework assignment I will just try and help with the general idea of how to solve this, instead of writing the code for you.





They basically want you to write a function that will check if the two vectors have all the same elements in them if you remove all of the duplicate numbers.





So how do you do this, well there are lots of ways.





The simplest is probably to sort them and then walk through the two vectors comparing them to one another as you skip over duplicate entries.





But there are plenty of other ways to accomplish the same thing.


C++ program help?

i want to write a function that get the size and the max element in an array using pointers , plz help me !!

C++ program help?
This is a pretty good exercise to learn a few things about pointers. The somewhat tricky part of this is that your function doesn't know how big the array is; actually, you want it to tell you how big it is. Kind of silly, since the caller is likely to know the size already, but hey, it's just an exercise. One approach, as I've done below, is to have a well known value that marks the end of the array. Slightly more clever would be to have the caller pass in the end marker to the function, rather than having it be a global.





Note also that there's nothing particularly C++ - ish about this code. Except for the cout statement, it's C.





If this is for an assignment, don't just turn in my code as if it were your own. Study my code, learn something, then code it for yourself. Since this is such fundamental stuff, your code may look a lot like mine, which is ok.





#include %26lt;iostream%26gt;


#include %26lt;climits%26gt;





using namespace std;





void sizeMax(int *, unsigned *, int *);





static const int END = 0xDEAD;





int data[] = { 10, 3, 42, 1, -1, 11, 0, END };





int main(int argc, char *argv[]) {


unsigned size;


int max;





sizeMax(data,%26amp;size,%26amp;max);


cout %26lt;%26lt; "size = " %26lt;%26lt; size %26lt;%26lt; ", max = " %26lt;%26lt; max %26lt;%26lt; endl;





return 0;


}





void sizeMax(int *a, unsigned *size, int *max) {


int *p;


*size = 0;


*max = INT_MIN;





for (p = a; *p != END; p++, (*size)++) {


if (*p %26gt; *max) *max = *p;


}


}
Reply:#include %26lt;stdio.h%26gt;


#include %26lt;limits.h%26gt;





// macro to determine size of an array


#define SizeofArray(a) ((sizeof(a) %26gt; 0) ? (sizeof(a)/sizeof(*a)) : 0)





void GetMaxAndSize(int * pArray, int %26amp; nSize, int nMax)


{


nSize = SizeofArray(pArray);


nMax = INT_MIN;


int nIndex;


for(nIndex = 0; nIndex %26lt; nSize; nIndex++)


{


if(nMax %26lt; *pArray) nMax = *pArray;


pArray += 1;


}


}











// example


int Numbers[]={1,2,3,4,5,6,7,8,9,10};





int main(int argc, char* argv[])


{


int nSize;


int nMax;


GetMaxAndSize(Numbers, nSize, nMax);


return 0;


}

survey for money

C programming question:?

i have to make a program that shows a windwill; basically every second the character on the screen changes form / , | , \ , and - . we have to use putchar(), pointers, and this line of code:


setbuf(stdout, NULL);


I've tried 2 different things: one of them only shows '/' and doesnt change while the other doesnt replace characters but adds them: /-\|/-\|/-....


How could i make this work?

C programming question:?
ask ure teacher man
Reply:gotoxy()


C++ hourglass loop?

I'm attempting to write a program that makes an hourglass design using asterisks (*).The user inputs a number of rows and the program makes the hourglass based on how many rows are specified.


Here is an example: This would show if 5 was entered.


*****


-***


--*


-***


*****


This is what I have so far:


int main()


{


int n, rows;





cout %26lt;%26lt; "Enter number of rows (no more than 23):" %26lt;%26lt; flush;


cin %26gt;%26gt; rows;





for (n = 1; n %26lt;= rows; n++)


{


if (n %26lt;= rows)


cout %26lt;%26lt; '*' %26lt;%26lt; flush;


}


if ((rows + 1) % 2)


cout %26lt;%26lt; '*' %26lt;%26lt; flush;


else


cout %26lt;%26lt; " " %26lt;%26lt; flush;


return 0;





This amount of code gets me the first line of *'s. I can only use cntrl structures: if, if else, switch, while, for, do-while; and can only use single characters and single spaces. I'm not looking for the exact code because I do want to learn this, but I am stuck and any pointers would be greatly appreciated

C++ hourglass loop?
#include "CHourGlass.h"


#include %26lt;string%26gt;


#include %26lt;iostream%26gt;





using namespace std;





CHourGlass::CHourGlass(int aRows)


{


if( aRows %26lt; 3 || aRows %26gt; 23 )


throw new string("row number violation");





m_height = aRows;


m_width = 1+((aRows/2)*2);


}





CHourGlass::~CHourGlass()


{


}





void CHourGlass::display()


{


int iWidth = m_width;


for( int i = 0; i%26lt; m_height;i++)


{


cout %26lt;%26lt; center(abs(iWidth))%26lt;%26lt; endl;


iWidth-=2;


if( iWidth == -1)


iWidth -=2;





}





}





string CHourGlass::center( int iCount)


{


int iSpace = (m_width-iCount)/2;


string result = string(iSpace,' ')+string(iCount, '*');





return result;


}
Reply:The first thing you need to do is identify the algorithm/relationship that you want your program to reflect. For example, given the number of rows the user wants, how do you calculate the number of stars each row will have? From your example of 5 rows it appears that you do:


5


5-2


5-2-2


5-2


5





Which would reflect an hourglass, however what if you only have 4 or 3 or 2 rows?





Identify this first and your program will easily fall into place.





Good luck!


C++ help please?

all i need to do is get started





Write a program that uses a random number generator to display one of 20 phrases stored in an array of char pointers. Let the user keep asking for phrases as long as desired

C++ help please?
do you have a specific question?





heres a hint on the random aspect:





srand( time( NULL ) ) ;


int idx = 19 * static_cast%26lt;double%26gt;(rand() / RAND_MAX) ;
Reply:you have nice legs...


C++ - using a vector inside of a Node?

I'm trying to use a vector to keep a list inside of a node...the node class is going to be used in a graph, as each node or point in the graph, and the vector is going to be used as an array of "next" pointers to the other nodes in the graph.





However, I don't really know how to implement this...I have listed this as a value in the Node class:





vector%26lt;pair%26lt;Node%26lt;T%26gt;*,int%26gt; %26gt; paths;





and my constructor for a default node is as follows:





template %26lt;typename T%26gt;


Node%26lt;T%26gt;::Node()


: place(""), value(0), pathdata(NULL, 0), paths(NULL)


{


}





So I want the vector for each node to be called paths, but whenever I try to use paths inside of a method, such as add a path or remove a path (from the vector), I try calling paths.push_back() or paths.erase() and when I compile it, it says "paths not in scope."





How can I fix this?

C++ - using a vector inside of a Node?
I'm not sure about your exact compile error, but I know the VC++ compiler can get very confused when STL containers contain other STL containers. It seems to get confused about mataching up multiple %26lt; %26gt;. The way to get around this is to use spaces when you declare the container of containers. Experiment with adding a space after vector%26lt; (before pair), amd maybe even a space before Node. (Sorry, I'm not at a computer with a compiler to do the experiment myself)
Reply:what's your compiler?





Try to invoke paths via this pointer..





this-%26gt;paths.push_back() ...

survey questions

C programming!!!help!!!?

i cant understand clearly the uses of pointers arrays...what are macros??the preprocessor statements??





please briefly explain these to me...or give me some very USEFUL links....





thank you very much!!

C programming!!!help!!!?
You can get some help from


http://expert.myitcareer.org/


Can anyone write c/c++ program for this binary tree problem??

There is a binary tree , a node having three pointers -- Left child, right child, parent. Now the problem is to delete the tree in top-down fashion ie First delete parent %26amp; then child.

Can anyone write c/c++ program for this binary tree problem??
how's this?:





typedef struct tree_struct


{


tree_struct *parent;


tree_struct *child_right;


tree_struct *child_left;


} tree_struct;





void main(void)


{


tree_struct *root;





// create the root using malloc(), add branches to the tree.


// Null pointers are assumed to indicate no child.





// now its time to free the tree in the manner you described (root-first)


free_tree(root);


}





void free_tree(tree_struct *tree)


{


tree_struct self;





self = *tree; // copy child pointers, note how parent is never used


free(tree);





if (self.child_right != NULL)


{


free_tree(self.child_right);


}


if (self.child_left != NULL)


{


free_tree(self.child_left);


}


}


Segmentation fault in C program?

this program is for sorting the file and displaying it on monitor...........


this is working nice in window but give segmentation fault in unix





i m storing address of strings in array of pointers..and then sorting it with bubble sort





here is the small part of program





buffer is for storing strings


pS is array of string pointers





if u want whole program for debuggin mail me ank_rishi23@yahoo.com





while((*fgets(buffer,(BUFFER_LEN-1),fp... != '\0') %26amp;%26amp; (i %26lt; NUM_P))


{


pS[i] = (char*)malloc(strlen(buffer) + 1);


if(pS[i]==NULL) /* Check for no memory allocated */


{


printf(" Memory allocation failed. Program terminated.\n");


return;


}


strcpy(pS[i++], buffer);


}


last_string = i;





where can be segmentation fault...........?? plz find.....

Segmentation fault in C program?
since its working on windows, the segmentation fault could be that unix does not recognize something in it.





from what i know, windows and unix have different ways of representing data. some have larger sizes.





so the error could be in the size. check the malloc to see if its causing the segmentation fault
Reply:May is virus ``KIlls virus `` `


You have two memory? Have a memory problem of the ``


I think you ,so going to http://www.ePathChina.com


Question about command line arguments for C/C++, argv?

int main (int argc, char* argv[])





ok in this case,,, argv[] is supposed to be an array of pointers pointing to input





why is it possible to say


puts(argv[1])? //putstring





if argv is an array of pointers, wouldn't that print a memory address? but why then does it actually print the actual argument passed.





Don't we need to dereference it first... like


puts(*argv[1])?





I would greatly appreciate your help. Thanks!

Question about command line arguments for C/C++, argv?
You are correct in your understanding that argv is an array of pointers. So argv[1] is just a pointer. There are two critical insights to understanding this.





Critical insight #1: In C and C++, a pointer can be used as an array. So if you have a char*, that can point to either a single character, or to an array. Because of this, if you have "char *a;", the statements "*a" and "a[0]" are exactly the same thing. (Of course, you can't say "a[1]" if a is just a pointer to a single character. The results will be undefined.)





Critical insight #2: In C, strings (referred to in C++ as "C-style strings" to distinguish them from C++'s std::string class) are just arrays of characters. And when you pass a string (that is, a "char*") to puts(), the string itself is printed out, not its address.





Thus, if you say


char *foo = "bar"; puts(foo);


you will see "bar" as the program's output. Likewise, if you say


char *foo = argv[1]; puts(foo);


you will see the second argument to the program. (Why the second? Because argv[0] is the first argument.)





Something important to remember is that puts() will only print out strings. If you say "puts(3)" or "puts(argv)" your code won't compile. puts() always does the dereferencing on its own.
Reply:argv[1] stores address but *argv[1] gives the value stored at argv[1] address
Reply:It's not "an array of pointers pointing to input". It's actually a vector (or array) of char* (or strings) so each element in the vector is a null terminated string.





argv[0] is the program name


argv[1] is the first parameter passed to the program (separated by spaces)


and so on.





Hope that helps!!

surveys

C/C++ - nested objects/structs question?

I have a great idea of how to implement an algebra solving/simplfying program, but I need it to have a structure within itself. Here's what I mean:





struct thing {


thing *t1;


thing *t2;


int other;


};





As you can see, the struct uses itself, and therefore cannot define 'thing' until it is finished, making a sort of catch 22. Is there a way to do something like this? All it needs to do is store two pointers to other instances of the same data type and one integer. If it is possible with a class, that would work too.





The code can be completely different, as long as it does what I described or gives an alternate method.

C/C++ - nested objects/structs question?
Well my C is a bit rusty but I know it is officially impossible to declare a structure containing an instance of itself....talk about endless loop! so doubt C++ would allow it either as physically impossible.





Couldn't you make a small array to hold the pointers and int? you could use an ordinary do-while to loop through?
Reply:Pointers to similar structures or classes is a common concept in data structures. This is how things such as linked lists or trees. They have a structure with a pointer the same structure for the next one in the list or the children in the tree. Look up linked list in wikipedia to see what I mean.





Anyways, here is some code demonstrating what you want to do. This is in C, but you can do similar things with classes in C++. I also played with the variables a bit to demonstrate different ways of accessing the data.





#include %26lt;stdio.h%26gt;





//get the compiler to recognize Thing as its own data type





typedef struct Thing Thing;





//define the struct





struct Thing {


Thing *first;


Thing *second;


int val;


};





int main()


{


Thing o1;


Thing o2;


Thing o3;





Thing *p4;


Thing *p5;


Thing *p6;





//dynamicall created Things


p4 = (Thing*)malloc(sizeof(Thing));


p5 = (Thing*)malloc(sizeof(Thing));


p6 = (Thing*)malloc(sizeof(Thing));





o1.first = %26amp;o2;


o1.second = %26amp;o3;





o1.val = 1;


o2.val = 2;


o1.second-%26gt;val = 3; // does same as o3.val = 3





p4-%26gt;first = p5;


p4-%26gt;second = p6;





p4-%26gt;val = 4;


p5-%26gt;val = 5;


p4-%26gt;second-%26gt;val = 6; // does same as p6-%26gt;val = 6;





printf("%d\n", o1.val);


printf("%d\n", o1.first-%26gt;val);//same as printing o2.val


printf("%d\n", o3.val);





printf("%d\n", p4-%26gt;val);


printf("%d\n", p4-%26gt;first-%26gt;val); //same as printing p5-%26gt;val


printf("%d\n", p6-%26gt;val);





//free dynamically created objects


free(p4);


free(p5);


free(p6);





return 0;


}
Reply:first thought : try the 'this' pointer in a class .. might work as such





#include %26lt;iostream%26gt;


using namespace std;


class many


{


public:


int integer1;


many *ptr;





many()


{


integer1 = 0;


ptr = this;


}


};





void main()


{


many o;


cout%26lt;%26lt;o.integer1%26lt;%26lt;endl;





cout%26lt;%26lt;o.ptr-%26gt;integer1%26lt;%26lt;endl;


}
Reply:Use forward class/struct declaration, for example:





struct thing;





struct thing {


thing *t1;


thing *t2;


int other;


};


C/C++: Creating self-sufficient executables?

Hi!





I've tried to search online but I guess I don't have to right keywords in mind to find a satisfying result.





I have seen in the past software which seems to be self sufficient-- and by that I mean that every external library is included in the executable binary itself, so there are a few DLL's (besides the vital ones like mscrt, etc) needed by that program.





Considering I already have the source code of a certain library, is it possible to have it compiled and included in my final executable, rather than being a standalone DLL?





I dont need a in-depth actual explaination, but rather a few pointers (links, articles, manpages) to go into the right direction.





Thanks :)

C/C++: Creating self-sufficient executables?
Yes. DLLs are Dynamic Linking Libraries You want static libraries. Do a search on how to create (and use) static libaries for Windows with your compiler.
Reply:I can't tell you exactly because it depends on what compiler you are using and I don't remember exactly, but what you are looking for is how to compile without dependencies.





For certain compilers and frameworks (usually the microsoft ones) sometimes there will be DLL files you have no choice but distributing/using.


In executing a microprogram the address of the next microinstruction to be executed is in the following catego

a. determined by instruction register b). determined by stack pointer c. next sequential address d). branch

In executing a microprogram the address of the next microinstruction to be executed is in the following catego
I know, but you should do your own homework.





Hint: Its the next INSTRUCTION. Where would you expect it to be?
Reply:you should ask this question here:





http://mega-tokyo.com/forum.





there are not many hard-core assembly languages programmers here. And I believe I am one of the *very* few who even understand your question.


This is a question about data structures (linked lists) can anyone help?

Suppose cursor points to a node in a linked list (using the node definition with member functions called data and link). What statement changes cursor so that it points to the next node?


A. cursor++;


B. cursor = link( );


C. cursor += link( );


D. cursor = cursor-%26gt;link( );





Suppose cursor points to a node in a linked list (using the node definition with member functions called data and link). What Boolean expression will be true when cursor points to the tail node of the list?


A. (cursor == NULL)


B. (cursor-%26gt;link( ) == NULL)


C. (cursor-%26gt;data( ) == NULL)


D. (cursor-%26gt;data( ) == 0.0)


E. None of the above.





Why does our node class have two versions of the link member function?


A. One is public, the other is private.


B. One is to use with a const pointer, the other with a regular pointer.


C. One returns the forward link, the other returns the backward link.


D. One returns the data, the other returns a pointer to the next node.

This is a question about data structures (linked lists) can anyone help?
Question 1 - Answer: D


Question 2 - Answer: B


Question 2 - Answer: C*


*I can only assume "your" definition of the node class is a 2-way linked list. If the definition is of a single-direction linked list, then C is not the answer

survey monkey

How To Play The Keyboard?

Yes I know there is like 90 of these kinda questions, but nothing works that I have seen. I own a kinda out dated Keyboard, its like 7 or 9 years old. I dont have it with me right now, but if you ask what kind, I'll go get it and add it into detail. I know this:





Left:


C = thumb


D = pointer


E = middle


F = thumb


G = pointer


A = middle


B = ring


C = pinky





right:


C = pinky


D = ring


E = middle


F = pointer


G = thumb


A = middle


B = pointer


C = thumb





That I have mastered well. What I was is a GOOD infomation kinda site on easy songs to start then gradually move up. Dont say, 'Go to Google and look it up'. I cant always find what I need, so I ask you people. So if anyone can help, please do.

How To Play The Keyboard?
You're going to hate what I have to say:





You're on the right track, you just need to:





PRACTICE, PRACTICE, PRACTICE!
Reply:I have on piece of advice... get a teacher...
Reply:Do you know chords?


the triads? C-E-G = C? G-B-E = G?


this fingering, is started in C, turns out to be the song "Imagine".





any song can be played in one key, you know. They can be transposed.


Most older rock is 3 chords anyway. EDA, CFG stuff. 1-3-5.
Reply:I'm a piano player (shouldn't make any difference) but the fingering you use sounds all wrong to me. Place both thumbs on middle C. Just reviewed what you had. It's OK except that you reversed the hands. Carry on with the rest of my answer. I don't know web sites for the music but your local music store will have all levels of sheet music. If you don't want to learn to read music (and Sir Paul McCartney can't), then listen to the song you want to play in your head and work out the matching sounds on the keyboard. Start with nursery rhyme songs first and then move up according to your ability, inclination and tastes.


Code 4 n e caption in VB if i want to click on "no",thn the no button keeps on moving without gettng hold of c

how can i write a code for any caption for example,if i want5 to click on "no",thn the no button keeps on moving in the whole form.i.e.the pointer doest get hold of it.

Code 4 n e caption in VB if i want to click on "no",thn the no button keeps on moving without gettng hold of c
If I understand the question, you want to move the button around so it's impossible to click on it. What you want to do is track the mouse pointer location. Then write a conditional something like:


If mouse.left - button.left %26lt; 10 pixels or mouse.top - button.top %26lt; 10 then


mouse.left = random number


mouse.top = another random number


end if





That way if the mouse gets within 10 pixels of the button it moves. Use a random number generator to get the randoms.





For mouse location it might be X and Y coordinates instead of left and top


Can anybody tell me methods about how to pass a 2d array to a function in c language?

please tell me about function prototype if i have to pass a pointer to array related with a 2d array.which is best method to pass a 2d array to a function?

Can anybody tell me methods about how to pass a 2d array to a function in c language?
arrays in c are really just pre allocated pointers. You have a couple ways you can pass them to a function. you can declare your function to accept a 2d array





void myFunct(int array[5][5]);


to call it --


int myArray[5][5];


myFunct(myArray);





think of an array of integers as a pointer that points to the first integer in the array. when you use an index [ ] you are just telling it the offset from the starting pointer. so you declare an int x[5] array x would be a pointer essentially. if you want to access the third int x[2] that is telling the compiler take the pointer x (a memory location and add the size of integer * 2 to it. Basically it is just pointer math but the compiler does it for you to prevent memory leaks and helps prevent access of non-allocated memory.





you can actually allocate something dynamically and access with the array [] index feature.





int *x; //pointer of type int





//allocate a dynamic array of 5 ints


x = (int*) malloc(sizeof(int) * 5);





x[0] = 1;


//is the same as


*x=1;





x[1] = 2;


//is the same as


*(x + (sizeof(int) *1)) = 2; //manual pointer math











a 2d array is simply a pointer to a pointer.





int my2d[5][5];





the first index is pulling a pointer to the actual array (and since and array is simply a pointer) it's a pointer to a pointer.





if you wanted to pull out individual arrays you could





int my2d[5][5];


int *ptr;





//ptr is now an array of my2d[0][0-4]


ptr = my2d[0]


//ptr[4] is the same as my2d[0][4]





so another way to pass a 2d array would be.





void myFunct(int **array);





called by same


int myArray[5][5];





myFucnt(myArray);
Reply:pass a pointer to the array


How do I make a vector of items of a custom type in c++?

I'm getting pretty tired of using arrays, especially when the good folks who wrote the STL went to all of the trouble of providing vectors. I would like to use a vector to store items of a type that I create. For instance, if I have a type foobar that is an int, a double, a pointer, and a char, how do I make a vector of foobars and fill it?





Thanks!

How do I make a vector of items of a custom type in c++?
use vector of stl to know more go to codeproject.com

online survey

Can you please explain to me how to make a C++ class?

I have looked everywhere for the tutorials, but none of them explain the answer fully. I think I get a good idea of it, then I run into something I don't unbderstand, so then I look for another tutorial and they explain it in a whole diofferent matter that confuses me. So far, this is what I think a class is





class person


{


int age;


int height;


char *name; (which I have no Idea what a character pointer is for)


char *nationality;


char *gender;


}


occupation; (Would occupation be an object of the person class?





And please explain what constructors and deconstructors are, and what they are used for (I think constructors are used to bring an object to life)


I would prefer if you made a class with a deconstructor and constructor and explain in detail with as simple an explanatiopn as possible.


THANK YOU!!!!!

Can you please explain to me how to make a C++ class?
It appears to me that you are beginning to have the basics down.





A class is a template to be used in creating an object. The class defines properties (variables) and behaviors (methods) that the object will possess.





From your example, occupation is a property of a person, and can be a reference to an occupation object as you mentioned.





You could then go further and define a method called changeOccupation or setOccupation that will allow you to change the occupation of that person object.





This combination of property and behavior define a class.





Constructors:





person::person() {


//do nothing


}





or





person::person(int iAge, int iHeight, ...) {


age = iAge;


height = iHeight;


}





Constructors are special class methods that you use to create the class. These methods can contain code that sets the "initial conditions" of the object when it's created, or allow the user of the class to pass values that will be used to set these initial conditions of the object. For instance you could use the constructor to set the age, height, etc of your person object when you create them.





Destructors:





person::~person() {


cout %26lt;%26lt; "Exiting Person Class Destructor!!!" %26lt;%26lt; "\n";


}





Destructors are called when the object made from the class is being destroyed, and will allow the class to clean up after itself (for instance closing database connections, or cleaning up pointers, etc.)





Check out Bruce Eckel's "Thinking in C++" you can download them for free from his site. I think he does a great job of explaining programming languages so you can understand them... not just the "how" but also the "why".


Find a string in a given string in microsoft visual c++ w/o using the strstr() function or the string.find...?

how can i search a string in a given string by not using the strstr() fxn...





ex:


text1=ueccss


text2=ccss





output: text2 is contained in text1





**otherwise, not contained....





and i must not use a pointer,,,,,???


is it possible for only a single-dimension array??

Find a string in a given string in microsoft visual c++ w/o using the strstr() function or the string.find...?
this is in C


but you should understand it





int counter;


int counter2;


int counter3;


int found = 0;





for ( counter = 0; counter %26lt; strlen(text1) ; counter++) {


if (text2[0] == text1[counter]) {


// a character in text1 matches the first character in text2


// lets see if its a match


counter3 = counter + 1; // temporary counter


for ( counter2 = 1; counter2 %26lt; strlen(text2); counter2++, counter3++) {


if (text2[counter2] != text1[counter3]) {


found = 0;


break;


}


}


if (found) {


printf("string found\n");


break;


}


}





here is the logic:


Loop thru each character of text1 comparing the characters with the first character of text2. If there is a match, loop thru text2 comparing each character with text1 starting at the position or index of the first char that matched the first character in text2. But since we already compared the first char's , you actually start the second comparison loop at the second chars.





the second chars in this case would be:





c[this one-%26gt; c]ss for text2


and uec[this one-%26gt; c]ss for text1


I think I'm misunderstanding this line of code in C++?

What does this line do?





int* addr = new int[num];





It is making an array with a pointer? Or something? I've been studying for a final and doing my last programs in a class all day and the code is starting to blend together...

I think I'm misunderstanding this line of code in C++?
addr is a pointer to an array of num ints





This lets your program dynamically allocate the memory for the array, instead of having a fixed amount of memory by defining int a[1000], for example. You can't say int a[num]; it's not valid.





You use this when you'll be determining the size of the array programmically. It's then also common to see delete a[ ] later on to free the memory.





Check out this site:


http://www.fredosaurus.com/notes-cpp/new...
Reply:It creates a new array of num integers, and sets addr to the address if the first element of the array.


How can i go backwards in a character buffer in 'C'?

for example...if i hav to search for a "//" in a buff...


{


//asnbvfv hjegfub hgdyfgh cjs


}


and if my pointer is pointing to cjs.... how can i get back to //...???


thanx in advance

How can i go backwards in a character buffer in 'C'?
decrement your pointer-- and it will move back one char,


then check the dereferenced char value of where it's pointing now and the place it was pointing





do{


pointer--;


}


until ("/" == pointer[0] %26amp;%26amp; "/" == pointer[1] )





something like that, don't lock it up in some infinite loop...
Reply:Yes, you can decrement and increment the pointer as much as you want, provided the buffer still contains the characters, i.e. if they haven't been popped off a stack or something similar. In the case you're describing, you can simply set the pointer offset to zero to access the first character.





But perhaps you mean you're getting characters one by one from the keyboard or a file and want to go back and look at previous characters? In that case, as they come in send the characters to your own buffer which you can examine at will.





Bear in mind that pointer arithmetic is always a minefield and indexing something outside a buffer's valid range is a very common error.
Reply:Decrease the value of the pointer (for example, by using the -- operator) and it will go to the left. Increase it and it will go to the right.

salary survey

Am trying to trace a quote by an old "preacher" - C M Lochridge {?} "This is my King"?

A pointer to a web site or such would be appreciated.


This could be circa1950's

Am trying to trace a quote by an old "preacher" - C M Lochridge {?} "This is my King"?
S. M. Lockridge - Awesome!





http://www.ignitermedia.com/products/iv/...
Reply:Took a bit, but it's SM Lochridge. Here are the google results:





http://www.google.ca/search?hl=en%26amp;client...





Enjoy!
Reply:Dr. S. M. Lochridge


How do you declare an array in a structure in C?

Is this right?





typedef struct listStruct


{


char word[20];


int counter;





pointer ptr;


} list;

How do you declare an array in a structure in C?
That works. If you don't know how large the array will be, you could also use "char*" (a pointer), and then later use malloc() to get memory for the array (as in "word = (char*)malloc(NumOfCharacters*sizeof(cha... As you have it written, you just need to make sure never to try to put 21 characters in the array. :)
Reply:yes its right 10/10


How to fill an array in a function with c++?

how to pass the parameters?


is there any other way without pointer and please help me because I need a function that fill an array

How to fill an array in a function with c++?
Pass it normally, using the correct declaration. That is, if you had char someVar[], pass it to the function as char functionVar[]. Then treat the function argument as you would the real array.





%26gt; is there any other way without pointer


Read http://c-faq.com/aryptr/index.html . There's an equivalence between pointers and arrays in some cases, so that's why you can work with the formal argument like you would with a pointer. Go through the C FAQ I linked to. It's confusing, and takes time to digest.





If you really want to understand C++, you should get a serious book. For C++, it's C++ Primer by Lippman or Accelerated C++ by Koenig (both are suitable for beginners). To understand the C portion of C++, you may want to get yourself K%26amp;R's The C Programming Language.
Reply:you can't modify an array if you pass by value into a function you have to pass by referance. When you pass by value a copy of the array(or any object) is put on the stack( or heap) . The keyword here is copy. I'm sry but you have to pass by reference otherwise you break the rules of encapsulation.


How to convert byte into string in c language?

i m having pointer so structure which members are of BYTE type.........i want to convert them into string(to print vendor name) and into number(to print serial number).....how to do it...i m using vc++........

How to convert byte into string in c language?
Byte is equivelant to unsigned char in C++ with values (in binary) from 0000 0000 to 1111 1111. To convery byte into a string you would end up with a single unsigned char (simply by typecasting it). Not the ideal way to do this.
Reply:I don't understand what you mean. Is each letter a character type? Do you need to transfer that into one string? Or is it an array of bytes?

surveys

How to give tooltip to class properties in C# like Intellisence?

In .Net IDE We have Intellisence facility which will give automatically class methods and properties etc when we press dot(.) operator. While moving the mouse pointer on class properties or function names we will get help text about that properties. How can I give the help text to my class properties and functions.

How to give tooltip to class properties in C# like Intellisence?
You use XML comments. Basically, XML comments are tags that you put before methods, classes, etc... We enter these XML comments after a triple backslash.





Here is an example:





///%26lt;summary%26gt;A funtion that does something.%26lt;/summary%26gt;


///%26lt;param name="i"%26gt;I is some int...%26lt;/param%26gt;


///%26lt;param name="input"%26gt;Input is some string...%26lt;/param%26gt;


///%26lt;returns%26gt;Returns an int%26lt;/returns%26gt;


int DoStuff(string input, int i) {


...


}





For more info on XML comments and what tags are available, go here: http://msdn.microsoft.com/library/en-us/...


Why would you use reinterpret_cast in c++?

I think it's used to convert a pointer of one type to another by performing a "binary copy". What does that mean and why would you ever want to do that?

Why would you use reinterpret_cast in c++?
The reinterpret cast converts one pointer type to another. It does not perform a binary copy of the object.





Its best use is to convert a base pointer to a class back to the derived class type. for example:





class A


{


};





class B: public A


{


public:


int m_nVar;


};





// base pointer pointing to derived class


// has no access to m_nVar


A *aPtr = new B;





// cast base pointer back to derived class pointer


// has access to m_nVar


B *bPtr = reinterpret_cast%26lt;B%26gt;(aPtr);





You can also use it to cast char* to int*, or any other number of unsafe converstions, but this is not recommended.


How do I delete a vector in c++?

I want to delete the whole vector and everything inside it. I tried "delete ListViewText;" But I got this error:


error: type `class std::vector%26lt;std::string, std::allocator%26lt;std::string%26gt; %26gt;' argument given to `delete', expected pointer

How do I delete a vector in c++?
you can delete a vector only if you allocated it with "new"
Reply:either use delete operator if u have created it using new


or to clear the vector use clear function provide by vector
Reply:It sounds like you want to remove all the items inside the vector. In that case, use the clear method:





vector.clear();





There is also a "remove" method if you want to remove only specific ranges of the vector.


Can you write a "split" function in C?

I blew an interview because I screwed up my pointer arithmetic while parsing a string:





Here is the syntax:





prompt%26gt;./split "This Is an input string" " "





output:


This


is


an


input


string





or:


prompt%26gt;./split "This is an input string" "p"


output:


this is an in


ut string





I tried putting '\0' wherever the split character occurred, but I couldn't turn it into an array of substrings.





Any ideas?

Can you write a "split" function in C?
Only strlen, strcpy, and strcat, eh? That's pretty harsh. I think you have the right idea putting '\0' at the split points. Instead of creating an array of substrings, though, create an array of pointers to the substrings.





Pseudocode:





char *s points to your input string


S is an array of pointers to char


char *p declared to walk through the input string


initialize p = s, i = 0





do {


set S[i++] = p


set p to next split point


set *p = '\0'


p = p + 1


} until last substring found





How about that? You don't even need any of those string.h functions!
Reply:And you weren't allowed to use strtok?

survey monkey

How can i write this program in c?

A program like a phonebook of a cellphone, using linked-list, a double pointer, sort it by name, the user will have the choice to edit or delete an entry and save it in a binary file and get it again.

How can i write this program in c?
Hey


Create a structure with fields like Name, Phone Number, E-Mail, Fax (In my cell phone, i have these options).


Two pointers of type this structure. One to connect to next node and one to connect to previous node.


For more information and implementation of double linked list, view the following


http://www.daniweb.com/code/snippet94.ht...
Reply:Modules:





Linked List


Sorting


Save/Load File


User Interface that uses the above three modules





Write each one individually and test them before gluing them together.


Designing a Binary Search Tree in C++ ?

Design a class template Table as the table to store the information of the people and another class Person to represent each individual person of the people in a table. The data structure of a table is the pointer-based binary search tree (BST). A table of people is an object of the class Table. The information of each person is store in a node, which is an object of the class Person. A relational database is conceptually a collection of tables (files). A table is abstractly a collection of to records (attributes).The information of a person consists of her (his) name, sex (male or female), birthday, address, city and phone number. Assume the names of the people are unique. The search key is the person’s name. Our program should be able to save a table for use later. We should be able to retrieve the information of a subgroup of people based on a given criterion. I need Add , Print , Delete and Save functions.

Designing a Binary Search Tree in C++ ?
Yeah, please leave Computer Science. You'll never be any good at it, since you don't do your own work. The world doesn't need people like you writing software for Air Traffic Control, radiation therapy machines, or even financial institutions. Do us all a favor and become a hair stylist. The worst that will happen there is that you give someone a bad haircut.
Reply:Do your own homework... your not asking a question your asking someone to do it all for you...


Can anyone help me with a C program(no of days b/w dates) urgent.....??

Program is to find no. of days between 2 dates using pointer to structures

Can anyone help me with a C program(no of days b/w dates) urgent.....??
You can create simple date structure like that





struct date


{


int day;


int month;


int year;


};





void main()


{


struct date *d1, *d2;


d1-%26gt;day=10;


d1-%26gt;month=4;


d1-%26gt;year=1998;





//Similary you can declare d2 and so on and implement you code accrdingly





}








you can also visit my blog http://codesbyshariq.blogspot.com for more C, C++ programs


HOMONYMS : Can you figure out w/c part of the human body that each clue below represents?

%26gt; An accusing pointer


%26gt; pumping stations

HOMONYMS : Can you figure out w/c part of the human body that each clue below represents?
finger?


hearts?





These aren't homonyms which are words that sound alike, but have different meanings.
Reply:index finger





heart
Reply:um...your index finger and your heart?
Reply:index finger





gluteous maximus
Reply:Finger %26amp; heart valves
Reply:1 FORE finger 2 the HEART
Reply:#1 Index finger





#2. Heart
Reply:1) Index finger


2) Heart
Reply:index finger and heart are obvious answers, but do you really mean homonyms? or is this some kind of brit rhyming slang?
Reply:I dont know about the first, but could a pumping station be your mouth??

online survey

How to create a dictionary using C++ programming language?

need to use file, class, pointer

How to create a dictionary using C++ programming language?
___________





// Here is some skeleton code; you can flesh out the specifics:





#include%26lt;iostream%26gt;


#include%26lt;fstream%26gt;


#include%26lt;string%26gt;





using namespace std;





class Dictionary


{


private:





char alphabet;


string meaning;


string word;





public:





void getmeaning(std::string *p);





void search()


{


string word;





cout%26lt;%26lt;"enter a word :";


cin%26gt;%26gt;word;





getmeaning(%26amp;word);


}


}di;











void Dictionary::getmeaning(std::string *p)


{


string a,b;





// Assume there exists a dictionary dic.txt


// Remember to add proper error handling (file operation)


ifstream get("dic.txt",ios::in);





while ( !get.eof())


{


get%26gt;%26gt;a%26gt;%26gt;b;





if (*p==a){


cout%26lt;%26lt;a%26lt;%26lt;" "%26lt;%26lt;b;


}


}


}











int main(){


int ch;








cout%26lt;%26lt;"=D=I=C=T="%26lt;%26lt;endl;


cout%26lt;%26lt;"1.Show meaning"%26lt;%26lt;endl;


cout%26lt;%26lt;"2.Show word"%26lt;%26lt;endl;


cout%26lt;%26lt;"3.Exit"%26lt;%26lt;endl;


cin%26gt;%26gt;ch;





switch(ch)


{


case 1:


di.search();





break;


case 2:


string word;





cout%26lt;%26lt;"enter a word :";


cin%26gt;%26gt;word;





di.getmeaning(word);





break;


case 3 :


return 0;


}


___________





EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT


___________





What is a Map?





The map container class provides the programmer with a convenient way to store and retrieve data pairs consisting of a key and an associated value. Each key is associated with one value. (If you want to associate a key with more than one value, look up the multimap container class.)








A working C++ dictionary program. It makes use of the Find() function:





Description: http://cis.stvincent.edu/html/tutorials/...





Code: http://cis.stvincent.edu/html/tutorials/...








Note: don't forget to include code in case the user enters a search word that is not in the dictionary.





___________


I need a hint on a c program?

#include %26lt;stdio.h%26gt;








int main(void)


{


FILE *reportfile;





reportfile = fopen("E:\\report.txt","wt");


if (reportfile = NULL)


{


printf("Report file open failed");


fflush(stdin);


printf("press any ");


}


else


{


printf ("hello are you working");


}


return 0;








}


This code is only a piece of my program if you need the whole program let me know. My question is the following i need to write the output to a file not to screen shots. This is what i am doing right now and i am opening the file correctly but i am not sending any output to the file what do i need to use to send the output to the file. And what about if i want to use i function can show help with both questions one without a function and the other one with the function calling the file as a pointer.

I need a hint on a c program?
look at fprintf. Probably that is what you are looking for since you use fopen.





If you use open instead, look at write.
Reply:visit by blog





http://codesbyshariq.blogspot.com for more hints.
Reply:I don't understand your last sentence, but if you want to write to a file using a FILE *, try fwrite().
Reply:#include %26lt;stdio.h%26gt;





int main(void)


{


FILE *reportfile;





reportfile = fopen("E:\\report.txt","wt");


if (reportfile = NULL)


{


printf("Report file open failed");


fflush(stdin);


printf("press any ");


}


else


{


// the next line sends output to the open file referenced by reportfile


fprintf (reportfile, "hello are you working\n");


fclose(reportfile); // Must close file when finished with it.


}


return 0;


}


I need a little help in c++?

my first question is ::


1.why we use "*"(asterisk) when we declare variables of type pointer???


and the second one is ::


2.the output of this code is "value 1==10 / value2==20" could u tell me why? am a little bit confused.


int value1 = 5, value2 = 15;


int * mypointer;


mypointer = %26amp;value1;


*mypointer = 10;


mypointer = %26amp;value2;


*mypointer = 20;


cout %26lt;%26lt; "value1==" %26lt;%26lt; value1 %26lt;%26lt; "/ value2==" %26lt;%26lt; value2;


return 0;

I need a little help in c++?
* is dereferncing operator thing of letter which has address, *letter is content of the letter


== is assignment operator.


You may also contact a C expert to help you speeden up learning. Check websites like http://askexpert.info/
Reply:The asterisk indicates that you are declaring a pointer.


A pointer is just a 32-bit number that indicates a memory location.


If you omit the asterisk in %26lt;int * mypointer;%26gt; you will be declaring the variable of type integer, not its address.





The reason why you get that output is simple. Here is step by step.


Firs, you assign the values for value1 and value2 in this line:


int value1 = 5, value2 = 15;


Then you get the addres where value1 is stored and you save it with the pointer in this line:


mypointer = %26amp;value1; %26amp; means that you are getting the address, not the value.


After that you change the value stored in that address in this line:


*mypointer = 10; Actually you are changin the value of value1 not mypointer. * before mypointer indicates that you want to change the value.


The same goes for value2.


And that's why you get your output.
Reply:What you are asking is a complex(for a novice person) topic. I don;t think I could explain accuartely what you are asking for. I do however know of an excellent website that can explain it to you.





http://www.sparknotes.com/cs/pointers/wh...





Good Luck and feel free to email me with any more questions


The most accurate readings that you can take on an analog VOM are when the meter's pointer is at the?

A. extreme right.


B. near right.


C. extreme left.


D. center scale

The most accurate readings that you can take on an analog VOM are when the meter's pointer is at the?
The most accurate readings are near the right end of the scale, for two reasons. Any inaccuracy in your reading is a smaller part of the total voltage near full scale, and readings near the left end are likely to be off because of incorrect adjustment of the zero adjust screw. (You can adjust it, but it changes a little if you tilt the meter.) If "extreme right" means past the end of the numbers, you may be off there if the needle hits the stop. On meters with a mirror behind the needle, move to where the needle is in front of its reflection for the best reading.

salary survey

Need Help in making this c++ program?

Implement and thoroughly test a class named IVector that represents a


dynamic array of integers. It will have 3 private data members: int


capacity, int count, and int * items. The 'capacity' is the physical


size of the dynamic array (its actual number of elements). The 'count'


is the number of elements currently in use (indices 0, 1, ...,


count-1). The pointer 'items' points to the first element of the


dynamic array, which will be created by the operator 'new'.





Class IVector will have three constructors: 1) a default constructor


that creates an array of capacity = 2 and count = 0; 2) a constructor


with parameter int cap that creates an array of capacity = cap and


count = 0; and 3) a copy constructor with parameter "const IVector %26amp; V"


that creates an array that is identical to IVector V.





Class IVector will have the following public member functions: 1) two


getters that return the capacity and the count of an IVector object;


2) one declared "void Append( int item )" that adds 'item' to 'items'


at position 'count' and increments 'count' by one; 3) one declared


"void Insert( int index, int item ) "that adds 'item' to 'items' at


position 'index' and increments 'count' by one; and one declared "void


Delete( int index )" that deletes the item at position 'index' and


decrements 'count' by one.





Overload the operator '[ ]' to access elements of the vector by


subscript.

Need Help in making this c++ program?
What is the question?
Reply:Does not look easy. May be you can contact a C++ expert at websites like http://askexpert.info/
Reply:Sounds pretty straightforward to me. So do you always get your homework done this way? Explains a lot about the state of the Software Industry.....


I can not open my C or D drive with double click i have right click open to work, No errors shown?

When I double click any drive icon in my computer the pointer icon turns to busy icon but after few seconds it becomes normal but the drives can not open. I have to right click on drive and click open. Once the drive is open then I can double click on folders and work normally only the drives doesnt work

I can not open my C or D drive with double click i have right click open to work, No errors shown?
happended to me once your computer has a virus in it. If u look closely u will see that in the right click options u would also be getting an option for Auto Play. Now that should definitely no be there on local disk partitions. Try installing an Anti Virus. I suggest Nod32 u can get it here. Its a trial version but with full features and updates i used it to fix my computer when i had this problem.





http://www.eset.com/
Reply:There is this so called software that repairs Disk Drive errors which is infected by the virus FS6519.dll.vbs. Even though your anti virus had already deleted the virus. It still sits on your registry. You can use Disk heal to fix disk drive system info corruption. (Disk Heal is free) Report It

Reply:yes, It just happens some times.
Reply:you have some form of a virus or trojan...

survey

Saturday, May 22, 2010

How do I access the startbutton on the tool bar on a laptop without clicking with the pointer?

or better yet how can I restore my computer using c prompt?


and no I don't have any restore disks.

How do I access the startbutton on the tool bar on a laptop without clicking with the pointer?
I'm not sure about what you're trying to restore, but it sounds like your trying to navigate windows without a mouse.





The link below shows the keyboard shortcuts you can use.


For example, hitting ctrl and esc will bring up the start menu. Then clicking first letter of the item you want will highlight it (hitting r to get to the run section for example). If you have more than one item with the same first letter, hitting it repeatedly will cycle through the items.
Reply:On my laptop there is a little "window's flag" key at the top right of the keyboard. look for the flag on your keyboard
Reply:CTRL + ESC
Reply:Press the "Window" button on your keyboard...it's between CTRL and ALT. Try using System Restore to restore your PC, but if that doesn't work, try performing a repair install.


Read text from Console in C++ ?

Please i need the code to read a text any text from the console.


reading as string or pointer of array.


for example how can i read "Hello"


notice that user can enter any text so the could should read any string text the user entered....even i don't know what tayp should i use

Read text from Console in C++ ?
// reading a text file


#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


#include %26lt;string%26gt;


using namespace std;





int main () {


string line;


ifstream myfile ("the path of the .txt file");


if (myfile.is_open())


{


while (! myfile.eof() )


{


getline (myfile,line);


cout %26lt;%26lt; line %26lt;%26lt; endl;


}


myfile.close();


}





else cout %26lt;%26lt; "Unable to open file";





return 0;


}


How can i make one c++ program read the virtual memory of another?

This is my problem...i need to use 2 matrixes, for fast information channels...in my algorithm. I can declare one of them in a program. If i declare both, then the program crashed (apparently due to some windows xp mem limit per program. When i declare 1 matrix in one program, but another in another program, and try to run both...i just get an error message saying that my page file is too small...so if i run this on a better computer, i'd be able to declare both matricies at once from two places. Now, i need to make the first program communicate with the second.


I want the first program to declare a matrix/array...get the memory address for the first element of the array, and length, and send that info through a text file to the other program...that would then take that number...load it into a pointer, and view the matrix without declaration. But this isn't working, why not?

How can i make one c++ program read the virtual memory of another?
There are a few ways that shared data can happen.





- create a RAM drive that has fast access. Then use both programs to open the same file. This is a GET IT DONE method.





- my second suggestion is what you have tried. But here is what might be wrong. Both programs have to be compiled, using the same compiler options. As I recall, if you use a LARGE scale object option, the pointers might work out universally. (the type of computer is not relavant).





- The other option is to install an ODBC text file or other global data structure. This could be an awesome and transportable method that would work on countless Windows computers of different flavors and environments. (Yet, I could not even begin to describe the programming details).





Good luck
Reply:I don't think you can just access shared memory on a whim, each modern program loads onto a computer in a separate memory space, the only way to communicate is through API calls, and memory addresses shouldn't be passed in them.





The other way is piping one program output into a master program but that is not going to solve your problem; in other words, without declaration is unlikely.


Need help fixing my C++ program.?

I need help getting my program to compile.





...


void rotate(Point%26amp; p, double angle)


{


double new_x = (((p.get_x()*cos(angle))


+(p.get_y()*sin(angle))));


double new_y = (((-(p.get_x())*sin(angle))


+(p.get_y()*cos(angle))));


double dx = new_x- p.get_x();


double dy = new_y- p.get_y();


p.move(dx,dy);


}


...


int main()


{





cout%26lt;%26lt; "The original point p (5,5) rotated 5 times by 10 degrees then scaled 5 times by .95 is:""\n";


Point p(5,5);


double angle = 10;


double scale = .95;


int rotation_count = 0;


int scale_count = 0;








while (rotation_count%26lt;5)


{


rotate(p, angle);





cout%26lt;%26lt; "The point is now " %26lt;%26lt; p.get_x %26lt;%26lt; "," %26lt;%26lt; p.get_x %26lt;%26lt; "\n";


rotation_count++;


}


...


This is the error I recieve


Error 1 error C3867: 'Point::get_x': function call missing argument list; use '%26amp;Point::get_x' to create a pointer to member d:\my documents\visual studio 2005\projects\a3q2\a3q2\assgn3q2.cpp 52





line 52 : cout%26lt;%26lt; "The point is now " %26lt;%26lt; p.get_x %26lt;%26lt; "," %26lt;%26lt; p.get_x %26lt;%26lt; "\n"

Need help fixing my C++ program.?
you forgot the parenthesis on the method calls:





line 52 : cout%26lt;%26lt; "The point is now " %26lt;%26lt; p.get_x %26lt;%26lt; "," %26lt;%26lt; p.get_x %26lt;%26lt; "\n"





should be:





line 52 : cout%26lt;%26lt; "The point is now " %26lt;%26lt; p.get_x() %26lt;%26lt; "," %26lt;%26lt; p.get_x() %26lt;%26lt; "\n"





-devon

land survey

Anyone good at C++? need quick help at least point me in the right direction?

Write a function that adds the elements of two 3-D arrays of size [n] [2] [2]. Create and initialize a 3-D array with n=2 where all of the elements are initialized to 2. Test the function by using it to add the array to itself. Next create a 3-D array with n= 3 where all of the elements are initialized to 3. Again test the function by using it to add the array to itself.





2: Write a function to print out the elements of arrays of size [n] [2] [2]. Use the function to print the results from the above two additions.





3: Write another function to add the elements of 3-D arrays of size [n] [2] [2], except use pointer arithmetic inside the function to implement the addition. Test the function.





I know how to create basic functions but as far as arrays, I have no clue even what arrays are. I just need guidance on this, i'm not asking anyone to do this problem. Code examples would be great though.

Anyone good at C++? need quick help at least point me in the right direction?
arrays are really a simple concept.


Arrays are basically a collection of variables which belong to the same data type.


for example this a integer array :: 1,34,54,3,45,56,67,34


and its size is eight ,since it has eight elements.


The above example is a one-dimensional array


syntax to declare a 1-dimentional array ::


%26lt;datatype%26gt; %26lt;variable name%26gt;[%26lt;size%26gt;]


example for an integer array :: int numbers[8];


example for a float array :: float numbers[8];


Now to Access a single element value in the array you can use the index number. for example if we take the array example above and use this line of code ::cout%26lt;%26lt;number[1];


the output will be 34. the elements position starts from 0 to n-1 n being the number of elements.





You can have multi dimensional arrays too.


suppose you want to represent a matrix then you can use a two dimentional array. 2 dim arrays will have two indexes like numbers[2][3]. This means the third element in the 2nd row.
Reply:You really need to just read the chapter on arrays in your text book. Arrays and pointers are fundamentals for the C++ language -- if you don't understand them you will fail at being able to master the language.
Reply:It's highly unlikely that your teacher would have given you an assignment which asks for three dimensional arrays without you having ever heard of them before. I would suggest listening in class, it'll do wonders.





Your teacher/professor will no doubt be more than happy to explain what an array is and how to use it, and will do a much better job than any online resource, so I would strongly suggest asking him or her. Nevertheless, here's a breif explanation:





Arrays are variables which store a set of values - for instance, an array of integers will let you store a set of integers all under one variable name, and then you access each individual item with [ ]. So for instance, once you've created and filled an array, you can access the first item in the list with 'varName[0]' and the second with 'varName[1]' and so on. Two dimensional arrays are an array of arrays, which you can visualize like a grid or table. And if, for instance, you wanted to access the second item in the third array, you'd say 'twoDArray[3][2]'.


Creating an array of structures within another strucure in C.?

i have an assignment that involves creating a Graph ADT. within this i need to have an array of Lists.





my List ADT is basically a doubly linked list with certain functionality. to create a new you call the function:





ListRef newList();





NOTE: ListRef is defined as "typedef struct List* ListRef". i.e., its just a handle/pointer to a List structure.





the problem is that you don't know the size of the graph until run time since you create a new one with the function:





GraphRef newGraph( int n );





where n is the number of vertexes in the graph (and thus the size of the array of List ADTs) and a GraphRef is just a pointer to a Graph structure.





i'm trying to do something like this:





struct Graph{


.


.


ListRef* list_array;


.


.


}





GraphRef newGraph( int n ){


GraphRef G = malloc(sizeof(Graph));


ListRef L[n];


.


.


for( i=0; i%26lt;n; ++i){


L[i] = newList();


}


G-%26gt;list_array = L;


.


.


}





But this results in no Lists being created (they are NULL) and then a core dump. what is wrong?

Creating an array of structures within another strucure in C.?
I think that the problem is that your ListRef array is being defined on the stack in the function newGraph(int n).





Once the function scope is over, G-%26gt;list_array will be pointing to a location that it doesn't own, and the first operation that it performs on it will cause a core dump.





What you need to do instead is to create your G-%26gt;list_array using malloc:





G-%26gt;list_array = (ListRef)malloc(n*sizeof(ListRef));





and then continue as before.





Hope this helps.





P.S. Interesting problem by the way :).