why i get 2 syntax errors here .

This is a discussion on why i get 2 syntax errors here . within the C Programming forums, part of the General Programming Boards category; I cant see the reason for the syntax error in this code? Code: #include <stdio.h> int what (char *st1,char *st2){ ...

  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
    22,313
    The variable named st was never declared but was used.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 02:29 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. errors syntax
    By bazzano in forum C Programming
    Replies: 2
    Last Post: 09-30-2005, 03: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

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