Thread: why i get 2 syntax errors here .

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    why i get 2 syntax errors here .

    I cant see the reason for the syntax error in this code?
    Code:
    #include <stdio.h>
    
    int what (char *st1,char *st2){
    	char  *p=st1;
    
    	if (*st2|| *st1) {
    		if (*st1=='\0') return 0;       //here something regarding variable assigning
    		while(*st1 && *st2 && *st1==*st2) st++;    // and here
    		if (st==p) return 0;
    		return what(st1,st2+1);
    	}
    	else
    		 return 1;
    }
    
    
    
    int main() {
    	char str1[]="aaabbbbbbcd" , str2[]="abcd" , str3[]="abd" ,str4[]="abcde";
    
    	printf("%d %d %d\n",what(str1,str2),what(str1,str3),what(str1,str4));
    return 0;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    The variable named st was never declared but was used.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. errors syntax
    By bazzano in forum C Programming
    Replies: 2
    Last Post: 09-30-2005, 02:44 AM
  4. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM
  5. Expression/Declaration Syntax Errors
    By fuh in forum C++ Programming
    Replies: 2
    Last Post: 01-15-2003, 06:49 PM