0
#include<cstdio>
#include<string>
#include "inventory.h"
#include "node.h"
#include<iostream>
using namespace std ;
int main (){
    inventory*obj1=new inventory();
     int size;
    int id,i;
     char A[100];
    char S_string;
    cout<<"plz enter the size of the list "<<endl;
    cin>>size;
    for(i=0;i<100;i++){
    cin>>S_string;
    A[i]=S_string;
    }
    int a=strcmp(A[i],"new");
    if(a==0){
    for(int j=0;j<size;j++){
        cout<<"enter the id"<<endl;
        cin>>id;
        obj1->new_id(id);
    }
    }
getchar();
getchar();
return 0; 
}

it gives me a red line under (A[i]) in [(A[i],"new")];
what should I do ?

2
Contributors
1
Reply
16
Views
2 Years
Discussion Span
Last Post by sepp2k
0

First of all you need to include string.h, not string, to get the declaration of strcmp (or even better keep including string, use the string class and don't bother with strcmp at all).

Secondly A is an array of chars, not strings or char pointers, so A[i] is a char and thus not a valid argument to strcmp. It also can't possibly be equal to "new" for that reason.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.