Expected primary-expression before ',' token error

Hello and thanks for taking the time to help me. I am writing a program that prints a dagger-like design to the screen but I keep getting the above error for my program in lines 30 and 34:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
using namespace std;
int display(char ch, int n)
{
    for (n=0; ch<n; ch++) 
    {
        cout <<"*";
    }
    
    for (ch=0; ch<n+1; ch++)
    {
        cout <<" " <<endl;
    }
    
    return ch;
} 
int main ()
{
    int target, whitespace, pattern;
    
    cout <<"Enter a whole number for a work of art. ";
    cin >>pattern;
    
    whitespace = 0;
    target = 1;
    
    while (pattern>0)
    for (whitespace=0; target<=10; target++)
    {
       pattern = display(*, target);
    }
    for (target=0; target<=10; target--)
    {
       pattern = display( , target);
    }
        
    system("pause");
    return 0;
}


After searching through other sites on this problem, it seems a syntax error. I've read the tutorial but it must be something so obvious it's not jumping out at me :P

(yes, I'm quite aware my program is probably wrong for what I want it to do, but I would like to figure that part out for myself, I just learn better that way.)
Try pattern = display('*', target);

Without the single quotes the compiler thinks * is multiplication operator and not a char.

Same with other line. If you want a space use ' '.
You may need to enclose you character with ' '. like
'*'. For charatcers, its's just single quotes like: ' <-- that. not: " <-that.
You probably already know that though.
Last edited on
Thanks a lot guys! I thought it would have been something silly like that.
Topic archived. No new replies allowed.