User Profile

Collapse

Profile Sidebar

Collapse
Natasha26
Natasha26
Last Activity: Feb 11 '09, 08:35 PM
Joined: Mar 24 '08
Location: London
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Natasha26
    replied to help with counting substings in strings???
    in C
    According to link, strstr returns a pointer to first occurrence of the search word in the given sentence. So you could test something like this:

    Code:
    char sentence[200], word[200]; 
    char* occurs_at; 
    int location; 
    
    [i]//code to get user inputs for: sentence and word, then:[/i]
    
    occurs_at = strstr(sentence, word);   [i]//a pointer (to somewhere in sentence)[/i]
    if(occurs_at)  [i]//if true[/i]
    ...
    See more | Go to post

    Leave a comment:


  • Natasha26
    replied to break exit what?
    in C
    Good point! In my defence though, he used a string literal ("...") and those are null-terminated, so when reached, the while will loop will evaluate to false.
    See more | Go to post

    Leave a comment:


  • Natasha26
    replied to Character Arrays in C
    in C
    When you declare a static array, you can do either of the following:
    Code:
     int arr1[3] = {1,2,3}; // or int arr1[3]; arr1[0]=1; arr1[1]=2; arr1[2]=3;
    int arr2[] = {1,2,3}; //compiler creates array of 3 and initialises them with the given values
    char arr3[] = "hello world!"; //compiler creates char array of length 12+1. the last character being the '\0' to indicate end of char array (this is a special case), and initialises
    ...
    See more | Go to post

    Leave a comment:


  • Natasha26
    replied to break exit what?
    in C
    Actually, u can modify the while(...) test too. Use while(name[i]), when the end of string is reached, name[n-1] will return '\0' which just evaluates to false and the while loop exits, either that or the if(...) test will take care of the exit when it encounters a punctuation character....
    See more | Go to post

    Leave a comment:


  • question on complicated pointer/reference declarations

    I came across some strange declarations and am trying to get the hang of it. Any comments on how to read and use such decl. will be most welcomed.

    1) Not sure if i understand this one. It could be that function f can be used to increment the address of a pointer. So to use f(...) give it an argument of type: int*

    Code:
     void f(int*& i) { i++; }
    2) I got this one from pg35 of "C++ in a nutshell,"...
    See more | Go to post

  • Natasha26
    replied to Text overlays on simple images
    in C
    I used the OpenCV library, it's all C functions. Very easy to load, modify (draw, text etc...) and display images....
    See more | Go to post

    Leave a comment:


  • brrrr.... Look Dries, you should appreciate that someone actually volunteered to help. On another note, I think Cats has a good solution to try out.

    (Besides the external location of your functions), it seems that you can get the desired function name (and arguments) from a user. Unfortunately this is only in string/char representation and can't be directly converted into a function name at runtime (if u can do that, let me know plz)....
    See more | Go to post

    Leave a comment:


  • Natasha26
    replied to Initialising struct in C++
    in C
    Well spotted weaknessforcats ! Also thank you Raghuram. Cheers guys. T....
    See more | Go to post

    Leave a comment:


  • Natasha26
    replied to Initialising struct in C++
    in C
    I wrongly copied & pasted my code. Sorry about that, but that's not the problem. I can't initialise the inherited structure using ={.,.,..};...
    See more | Go to post

    Leave a comment:


  • Natasha26
    replied to soring of arrays in increasing order
    in C
    Have u tried anything? Bubble sort perhaps, very easy 101 stuff....
    See more | Go to post

    Leave a comment:


  • Natasha26
    started a topic Initialising struct in C++
    in C

    Initialising struct in C++

    I was playing around with struct and realised that when i inherit from a base-class, i can no longer initialise the inherited struct the way i'm used to.

    Code:
    struct Date{[indent]int dd, mm, yy;[/indent]
    }
    
    struct Employee{[indent]char* fname, *lname;
    Date hiring_d;
    short dept;
    [/indent]
    };
    
    struct Manager : public Employee{[indent]short level; //i've tried commenting this line for furher testing but no luc[/]
    ...
    See more | Go to post

  • Natasha26
    replied to array of strings
    in C
    Just a quick check. Does the following sound ok to anyone? It works, but i don't know whether the array gets de-allocated after main() ends?
    Code:
    #include <iostream>
    
    int main()
    {[INDENT]    char* fname[3];
        
        fname[0] = "aaa";
        fname[1] = "bbb";
        fname[2] = "ccc";
        
        for(int i=0; i<3; i++)
            std::cout << "\n"[/]
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...