User Profile

Collapse

Profile Sidebar

Collapse
drjay1627
drjay1627
Last Activity: Dec 7 '08, 07:22 PM
Joined: Nov 21 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • drjay1627
    replied to data structure question
    in C
    Well I didn't write code. I hate to write code on paper.

    I wrote what need to be done.

    //Iterate through the vector
    //if( iter == index)
    // return element_type


    something similar to this.
    See more | Go to post

    Leave a comment:


  • drjay1627
    started a topic data structure question
    in C

    data structure question

    Hello,

    Can someone help me with the answer for this question. This is an exam I did a couple of week back and I don't understand why I got it wrong. AND I don't understand the answer the instructor gave me either.

    QUESTION

    Suppose the following partial definition for a vector class. Fill the method indicated below so that it functions as described in the comments. You should write your answer in C++ or...
    See more | Go to post

  • drjay1627
    replied to map<string,string> error
    in C
    figured it out... thanks!
    See more | Go to post

    Leave a comment:


  • drjay1627
    started a topic map<string,string> error
    in C

    map<string,string> error

    I need help with inserting a string for both key and value to a map.

    Code:
    while(!myHuffFile.eof()){
    		string word, code;
    		int freq;
    		myHuffFile >> word >> freq >> code;
    		if(word == ""){
    			break;
    		}else{
                            _fileMap.insert(pair<string,string>(word,code));
    			_freqMap.insert(pair<string,int>(word,freq));
    ...
    See more | Go to post

  • drjay1627
    replied to stl/map and string question
    in C
    what if the you dont know the length of the string?
    See more | Go to post

    Leave a comment:


  • drjay1627
    replied to stl/map and string question
    in C
    what is the way around it?
    See more | Go to post

    Leave a comment:


  • drjay1627
    started a topic stl/map and string question
    in C

    stl/map and string question

    I have string and a map<string,int>

    i need to iterate through the map and find string[i] and replace the int with the string.

    eg: if map contains

    hello 6
    world 4
    its 3
    me 60

    if the string is "its me hello world world hello"

    output should be "3 60 6 4 4 6"

    Code:
    for(int i = 0 ; i < str.length() ; i++){
    ...
    See more | Go to post

  • drjay1627
    replied to switch case statements question
    in C
    Code:
    bool caseFlag = false;
    while(!caseFlag){
    	switch (option){
    	case 'y' :
    		remove("file.txt");
    		caseFlag = true;
    		break;
    	case 'n' :
    		caseFlag = true;
    		exit(0);
    	default :
    		cout << "Invalid entry" << endl;
    		cin >> option;
    		caseFlag = false;
    	}
    }
    this fixed it!
    See more | Go to post

    Leave a comment:


  • drjay1627
    replied to switch case statements question
    in C
    ok i used a boolean and a while loop and fixed it but shouldnt the case statement take care of any invaild input???
    See more | Go to post

    Leave a comment:


  • drjay1627
    started a topic switch case statements question
    in C

    switch case statements question

    how do i make sure that the switch case doesnt ternimate the program if the entry is invalid.

    in my program, if user input is y, removes the file. if user input is n, exits program, if user input is anything else prints out error message prompts for user input again and if that is a invalid input it terminates program. i dont want it to terminate the program. until the correct input is entered, it needs to prompt the user.
    ...
    See more | Go to post

  • drjay1627
    started a topic Incorrect output file: c++ (i/o) question
    in C

    Incorrect output file: c++ (i/o) question

    I encode a text file using a huffman tree. Which print out to the screen and and output to a file. File only contains the last line that prints to the console.

    Code:
    void traverse(string code = "") const {
    		string outputFile = "huffman.txt";
    		ofstream outfile(outputFile.c_str());
    
    
    		if (child0 !=NULL) {
    
    			static_cast<huffman_item<dtype> >( *child0).traverse(code
    ...
    See more | Go to post

  • drjay1627
    replied to adding # of spaces in string to map
    in C
    I figured it out! But couldn't have done it without your help mate!

    instead of => tempVec.push_ba ck(spaceLine.su bstr(x, x+1));
    I did => tempVec.push_ba ck(spaceLine.su bstr(x, 1));

    When its x+1 the first substring will be an empty string with size 1 an second will be empty string with size 2 and so on... Because we loop through the string.

    tempVec.push_ba ck(spaceLine.su bstr(x, 1)); does what...
    See more | Go to post

    Leave a comment:


  • drjay1627
    replied to remove punctuation in C
    in C
    thanks! didn't know that ASCII values were different! when you say platform is the OS you talking or compiler?

    If OS, my programs worked on both linux and windows, and if compiler my program compiles on VS and g++....
    See more | Go to post

    Leave a comment:


  • drjay1627
    replied to remove punctuation in C
    in C
    why not??? what do you suggest?...
    See more | Go to post

    Leave a comment:


  • drjay1627
    replied to remove punctuation in C
    in C
    I haven't done this in C but have done this in C++, java and C#.

    psuedo code:

    string someFunction(st ring string){
    string str;
    for(int i = 0 ; i<string.size( ) ; i++) {//loop through the main string passed in character by character
    char j = string[i];
    if(j>=65 && j<=90 || j>=97 && j<=122 || j == 32 || j>=48 && j<=57){ //these numbers are ascii...
    See more | Go to post

    Leave a comment:


  • drjay1627
    replied to adding # of spaces in string to map
    in C
    i did what you said this is the output i get:

    vector "hello"
    vector "world"
    vector "apple"
    vector "cat"
    vector "hello"
    vector "world"
    vector " "
    vector " "
    vector " "
    vector " "
    vector " "
    vector " "
    vector " "...
    See more | Go to post

    Leave a comment:


  • drjay1627
    replied to adding # of spaces in string to map
    in C
    This is not my assignment mate... yeah this is how my instructor wants... basically I making a word frequency map to be encoded using a huffman code.

    project is read in a very large text file, and encode it....
    See more | Go to post

    Leave a comment:


  • drjay1627
    replied to adding # of spaces in string to map
    in C
    I'll try that mate thanks!...
    See more | Go to post

    Leave a comment:


  • drjay1627
    started a topic adding # of spaces in string to map
    in C

    adding # of spaces in string to map

    hello,

    This is my 1st post here!

    *welcome drjay*

    Thanks! I look answering questions and getting answers to other!

    Now that we got that out of the way. I'm trying to read in a string and add the unique words in the string to a map. Eg:

    string = "hello world! hello world... I'm a live"

    map<string,int>

    hello 2
    wold 2
    ...
    See more | Go to post
No activity results to display
Show More
Working...