string roll

This is a discussion on string roll within the C++ Programming forums, part of the General Programming Boards category; 18 C:\Dev-Cpp\project333 misc\cvc3roll.cpp expected primary-expression before ']' token Code: /* cvc3.h */ // roll string #ifndef CVC3ROLL_H #define CVC3ROLL_H void ...

  1. #1
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638

    string roll

    18 C:\Dev-Cpp\project333 misc\cvc3roll.cpp expected primary-expression before ']' token
    Code:
    /* cvc3.h */
    
    // roll string
    
    #ifndef CVC3ROLL_H
    #define CVC3ROLL_H
    
    void rollup( char b[]) {
         for(int a; a < sizeof b ; a++ ) {
    ...
    // roll func() 
                }
                // std::cout << b << endl ;
                 }
                    
             
    #endif 
    
    
    /* cvc3.cpp */
    
    #include "cvc3rolle.h"
    #include <iostream>
    
    using namespace std;
    
    int main(){
        
       char q[]  = "ababdddd test text of string for roll " ;
     
       for(int a = 0 ; a < 2 ; a++ ) {
              rollup(q[]);
               cout << q << endl;
               }
    
    }
    have tried "rollup(q)" rollup(&q) and changed .h to *q have tried

    i know #define CVC3ROLL_H is diff from #include "cvc3rolle.h" .h mod several times seems not issue.

    thinking cpp say
    Code:
    //: C03:Return.cpp
    // Use of "return"
    #include <iostream>
    using namespace std;
    
    char cfunc(int i) {
     ...
    }
    
    int main() {
      cout << "type an integer: ";
      int val;
      cin >> val;
      cout << cfunc(val) << endl;
    } ///:~
    almost same prog. mine use char while tcpp use int. and i use .h

    tia any ideas ?

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I'd say change:
    Code:
    void rollup( char b[]) {
    to:
    Code:
    void rollup( char* b ) {
    or even better:
    Code:
    void rollup( std::string& b ) {
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    i tried it that way. void rollup(char *q) already. got error can not convert chr* to char**.
    took suggestion did it again with same error then i removed [] in the for loop. it compiled.

    ok tested it worked. i messed up the for loop function call.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Slicing problem with inherited classes.
    By Swerve in forum C++ Programming
    Replies: 6
    Last Post: 10-20-2009, 02:29 PM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21